From: Tobias Stoeckmann Date: Fri, 6 Mar 2026 20:58:46 +0000 (+0100) Subject: eject: Reset SIGCHLD to default for wait X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c12d45e4b93f2d87d68fe4095110b00b506ded5d;p=thirdparty%2Futil-linux.git eject: Reset SIGCHLD to default for wait If SIGCHLD is ignored, the wait call which waits for the umount command to finish could fail with -1 and ECHILD. Since its return value is not checked, the uninitialized status variable would be read, leading to undefined behavior. While at it, removed the additionally printed newline from errx message. Signed-off-by: Tobias Stoeckmann --- diff --git a/sys-utils/eject.c b/sys-utils/eject.c index 0debd0df3..5d6328312 100644 --- a/sys-utils/eject.c +++ b/sys-utils/eject.c @@ -671,13 +671,12 @@ static void umount_one(const struct eject_control *ctl, const char *name) break; default: /* parent */ - wait(&status); - if (WIFEXITED(status) == 0) + if (wait(&status) == -1 || WIFEXITED(status) == 0) errx(EXIT_FAILURE, _("unmount of `%s' did not exit normally"), name); if (WEXITSTATUS(status) != 0) - errx(EXIT_FAILURE, _("unmount of `%s' failed\n"), name); + errx(EXIT_FAILURE, _("unmount of `%s' failed"), name); break; } } @@ -863,6 +862,9 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } + /* clear any inherited settings */ + signal(SIGCHLD, SIG_DFL); + if (!ctl.device) { ctl.device = mnt_resolve_path(EJECT_DEFAULT_DEVICE, NULL); verbose(&ctl, _("using default device `%s'"), ctl.device);