if (n != 0) /* on success we should have read 0 bytes */
return -EIO;
- r = wait_for_terminate_and_check("(sd-userns)", pid, 0);
- pid = 0;
+ r = wait_for_terminate_and_check("(sd-userns)", TAKE_PID(pid), 0);
if (r < 0)
return r;
if (r != EXIT_SUCCESS) /* If something strange happened with the child, let's consider this fatal, too */
if (m->control_pid <= 0)
return;
- unit_unwatch_pid(UNIT(m), m->control_pid);
- m->control_pid = 0;
+ unit_unwatch_pid(UNIT(m), TAKE_PID(m->control_pid));
}
static void mount_parameters_done(MountParameters *p) {
if (s->control_pid <= 0)
return;
- unit_unwatch_pid(UNIT(s), s->control_pid);
- s->control_pid = 0;
+ unit_unwatch_pid(UNIT(s), TAKE_PID(s->control_pid));
}
static void service_unwatch_main_pid(Service *s) {
if (s->main_pid <= 0)
return;
- unit_unwatch_pid(UNIT(s), s->main_pid);
- s->main_pid = 0;
+ unit_unwatch_pid(UNIT(s), TAKE_PID(s->main_pid));
}
static void service_unwatch_pid_file(Service *s) {
if (s->control_pid <= 0)
return;
- unit_unwatch_pid(UNIT(s), s->control_pid);
- s->control_pid = 0;
+ unit_unwatch_pid(UNIT(s), TAKE_PID(s->control_pid));
}
static void socket_cleanup_fd_list(SocketPort *p) {
if (s->control_pid <= 0)
return;
- unit_unwatch_pid(UNIT(s), s->control_pid);
- s->control_pid = 0;
+ unit_unwatch_pid(UNIT(s), TAKE_PID(s->control_pid));
}
static void swap_done(Unit *u) {
assert(e->tar_fd >= 0);
if (e->tar_pid > 0) {
- r = wait_for_terminate_and_check("tar", e->tar_pid, WAIT_LOG);
- e->tar_pid = 0;
+ r = wait_for_terminate_and_check("tar", TAKE_PID(e->tar_pid), WAIT_LOG);
if (r < 0)
return r;
if (r != EXIT_SUCCESS)
i->tar_fd = safe_close(i->tar_fd);
if (i->tar_pid > 0) {
- r = wait_for_terminate_and_check("tar", i->tar_pid, WAIT_LOG);
- i->tar_pid = 0;
+ r = wait_for_terminate_and_check("tar", TAKE_PID(i->tar_pid), WAIT_LOG);
if (r < 0)
return r;
if (r != EXIT_SUCCESS)
gpg_pipe[1] = safe_close(gpg_pipe[1]);
- r = wait_for_terminate_and_check("gpg", pid, WAIT_LOG_ABNORMAL);
- pid = 0;
+ r = wait_for_terminate_and_check("gpg", TAKE_PID(pid), WAIT_LOG_ABNORMAL);
if (r < 0)
goto finish;
if (r != EXIT_SUCCESS)
pull_job_close_disk_fd(i->settings_job);
if (i->tar_pid > 0) {
- r = wait_for_terminate_and_check("tar", i->tar_pid, WAIT_LOG);
- i->tar_pid = 0;
+ r = wait_for_terminate_and_check("tar", TAKE_PID(i->tar_pid), WAIT_LOG);
if (r < 0)
goto finish;
if (r != EXIT_SUCCESS) {
}
static void bus_kill_exec(sd_bus *bus) {
- if (pid_is_valid(bus->busexec_pid) > 0) {
- sigterm_wait(bus->busexec_pid);
- bus->busexec_pid = 0;
- }
+ if (!pid_is_valid(bus->busexec_pid))
+ return;
+
+ sigterm_wait(TAKE_PID(bus->busexec_pid));
}
static int bus_start_address(sd_bus *b) {
}
}
- r = wait_for_container(*pid, &container_status);
- *pid = 0;
+ r = wait_for_container(TAKE_PID(*pid), &container_status);
/* Tell machined that we are gone. */
if (bus)
stdout_redirected = stderr_redirected = false;
(void) kill(pager_pid, SIGCONT);
- (void) wait_for_terminate(pager_pid, NULL);
+ (void) wait_for_terminate(TAKE_PID(pager_pid), NULL);
pager_pid = 0;
}
return;
/* Inform agent that we are done */
- (void) kill_and_sigcont(agent_pid, SIGTERM);
- (void) wait_for_terminate(agent_pid, NULL);
- agent_pid = 0;
+ sigterm_wait(TAKE_PID(agent_pid));
}
int ask_password_agent_open_if_enabled(BusTransport transport, bool ask_password) {
return;
/* Inform agent that we are done */
- (void) kill_and_sigcont(agent_pid, SIGTERM);
- (void) wait_for_terminate(agent_pid, NULL);
- agent_pid = 0;
+ sigterm_wait(TAKE_PID(agent_pid));
}
#else