Merge pull request #10741 from poettering/signal-check

propeperly handle sd_event_add_signal() errors
This commit is contained in:
Lennart Poettering 2018-11-12 19:03:22 +01:00 committed by GitHub
commit 7d7c8ea944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 13 deletions

View File

@ -732,12 +732,16 @@ int main(int argc, char *argv[]) {
(void) sd_event_set_watchdog(event, true);
r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
if (r < 0)
return r;
if (r < 0) {
log_error_errno(r, "Failed to install SIGINT handler: %m");
goto finish;
}
r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
if (r < 0)
return r;
if (r < 0) {
log_error_errno(r, "Failed to install SIGTERM handler: %m");
goto finish;
}
r = connect_bus(&context, event, &bus);
if (r < 0)

View File

@ -560,7 +560,9 @@ static int create_remoteserver(
if (r < 0)
return r;
setup_signals(s);
r = setup_signals(s);
if (r < 0)
return log_error_errno(r, "Failed to set up signals: %m");
n = sd_listen_fds(true);
if (n < 0)

View File

@ -751,12 +751,16 @@ int main(int argc, char *argv[]) {
(void) sd_event_set_watchdog(event, true);
r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
if (r < 0)
return r;
if (r < 0) {
log_error_errno(r, "Failed to install SIGINT handler: %m");
goto finish;
}
r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
if (r < 0)
return r;
if (r < 0) {
log_error_errno(r, "Failed to install SIGTERM handler: %m");
goto finish;
}
r = connect_bus(&context, event, &bus);
if (r < 0)

View File

@ -987,12 +987,16 @@ int main(int argc, char *argv[]) {
(void) sd_event_set_watchdog(event, true);
r = sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
if (r < 0)
return r;
if (r < 0) {
log_error_errno(r, "Failed to install SIGINT handler: %m");
goto finish;
}
r = sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
if (r < 0)
return r;
if (r < 0) {
log_error_errno(r, "Failed to install SIGTERM handler: %m");
goto finish;
}
r = connect_bus(&context, event, &bus);
if (r < 0)