Module Name: src Committed By: kre Date: Thu Feb 6 19:51:59 UTC 2020
Modified Files: src/bin/sh: main.c Log Message: If we are invoked with SIGCHLD ignored, we fail badly, as we assume that we can always wait(2) for our children, and an ignored SIGCHLD prevents that. Recent versions of bash can be convinced (due to a bug most likely) to invoke us that way. Always return SIGCHLD to SIG_DFL during init - we already prevent scripts from fiddling it. All ash derived shells apparently have this problem (observed by Martijn Dekker, and notified on the bash-bug list). Actual issue diagnosed by Harald van Dijk (same list). To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/bin/sh/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/main.c diff -u src/bin/sh/main.c:1.82 src/bin/sh/main.c:1.83 --- src/bin/sh/main.c:1.82 Sat Feb 9 09:33:20 2019 +++ src/bin/sh/main.c Thu Feb 6 19:51:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.82 2019/02/09 09:33:20 kre Exp $ */ +/* $NetBSD: main.c,v 1.83 2020/02/06 19:51:59 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; #else -__RCSID("$NetBSD: main.c,v 1.82 2019/02/09 09:33:20 kre Exp $"); +__RCSID("$NetBSD: main.c,v 1.83 2020/02/06 19:51:59 kre Exp $"); #endif #endif /* not lint */ @@ -109,6 +109,15 @@ main(int argc, char **argv) uid_t uid; gid_t gid; + /* + * If we happen to be invoked with SIGCHLD ignored, we cannot + * successfully do almost anything. Perhaps we should remember + * its state and pass it on ignored to children if it was ignored + * on entry, but that seems like just leaving the shit on the + * footpath for someone else to fall into... + */ + (void)signal(SIGCHLD, SIG_DFL); + uid = getuid(); gid = getgid();