diff options
author | Shawn Landden <slandden@gmail.com> | 2018-02-03 10:16:33 -0800 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:58:50 +0200 |
commit | 4ea9b5737fb009441667734864a08031152c671e (patch) | |
tree | 2e2ea252bc6dc2d554c7fb857929329ca0e8b726 /src/basic/process-util.c | |
parent | c204e302a5b8c276e846c0e36a746b12e8a16a8e (diff) |
sd-bus: cleanup ssh sessions (Closes: #8076)
we still invoke ssh unnecessarily when there in incompatible or erreneous input
The fallow-up to finish that would make the code a bit more verbose,
as it would require repeating this bit:
```
r = bus_connect_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
log_error_errno(r, "Failed to create bus connection: %m");
goto finish;
}
sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
```
in every verb, after parsing.
v2: add waitpid() to avoid a zombie process, switch to SIGTERM from SIGKILL
v3: refactor, wait in bus_start_address()
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r-- | src/basic/process-util.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index ba8b3d80f..ccf828389 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -813,6 +813,13 @@ void sigkill_waitp(pid_t *pid) { sigkill_wait(*pid); } +void sigterm_wait(pid_t pid) { + assert(pid > 1); + + if (kill_and_sigcont(pid, SIGTERM) > 0) + (void) wait_for_terminate(pid, NULL); +} + int kill_and_sigcont(pid_t pid, int sig) { int r; |