/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
-#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
if (r < 0)
return log_error_errno(r, "Failed to flock block device in child process: %m");
if (r == 0) {
- struct sigevent sev = {
- .sigev_notify = SIGEV_SIGNAL,
- .sigev_signo = SIGALRM,
- };
- timer_t id;
-
- if (timer_create(CLOCK_MONOTONIC, &sev, &id) < 0) {
- log_error_errno(errno, "Failed to allocate CLOCK_MONOTONIC timer: %m");
- _exit(EXIT_FAILURE);
- }
-
- struct itimerspec its = {};
- timespec_store(&its.it_value, timeout);
-
- if (timer_settime(id, /* flags= */ 0, &its, NULL) < 0) {
- log_error_errno(errno, "Failed to start CLOCK_MONOTONIC timer: %m");
- _exit(EXIT_FAILURE);
- }
-
if (lock_generic(fd, type, operation) < 0) {
log_error_errno(errno, "Unable to get an exclusive lock on the device: %m");
_exit(EXIT_FAILURE);
}
siginfo_t status;
- r = pidref_wait_for_terminate(&pidref, &status);
+ r = pidref_wait_for_terminate_full(&pidref, timeout, &status);
if (r < 0)
return r;
return 0;
case CLD_KILLED:
- if (status.si_status == SIGALRM)
- return -ETIMEDOUT;
-
- _fallthrough_;
-
case CLD_DUMPED:
return -EPROTO;