Date: Sat, 13 Jun 2009 21:20:02 GMT From: dfilter@FreeBSD.ORG (dfilter service) To: freebsd-bugs@FreeBSD.org Subject: Re: bin/74404: commit references a PR Message-ID: <200906132120.n5DLK2pp053617@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/74404; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/74404: commit references a PR Date: Sat, 13 Jun 2009 21:10:55 +0000 (UTC) Author: jilles Date: Sat Jun 13 21:10:41 2009 New Revision: 194127 URL: http://svn.freebsd.org/changeset/base/194127 Log: Don't skip forking for an external command if any traps are active. Example: sh -c '(trap "echo trapped" EXIT; sleep 3)' now correctly prints "trapped". With this check, it is no longer necessary to check for -T explicitly in that case. This is a useful bugfix by itself and also important because I plan to skip forking more often. PR: bin/113860 (part of) PR: bin/74404 (part of) Reviewed by: stefanf Approved by: ed (mentor) Modified: head/bin/sh/eval.c head/bin/sh/trap.c head/bin/sh/trap.h Modified: head/bin/sh/eval.c ============================================================================== --- head/bin/sh/eval.c Sat Jun 13 20:58:12 2009 (r194126) +++ head/bin/sh/eval.c Sat Jun 13 21:10:41 2009 (r194127) @@ -731,7 +731,7 @@ evalcommand(union node *cmd, int flags, /* Fork off a child process if necessary. */ if (cmd->ncmd.backgnd || (cmdentry.cmdtype == CMDNORMAL - && ((flags & EV_EXIT) == 0 || Tflag)) + && ((flags & EV_EXIT) == 0 || have_traps())) || ((flags & EV_BACKCMD) != 0 && (cmdentry.cmdtype != CMDBUILTIN || cmdentry.u.index == CDCMD Modified: head/bin/sh/trap.c ============================================================================== --- head/bin/sh/trap.c Sat Jun 13 20:58:12 2009 (r194126) +++ head/bin/sh/trap.c Sat Jun 13 21:10:41 2009 (r194127) @@ -222,6 +222,21 @@ clear_traps(void) /* + * Check if we have any traps enabled. + */ +int +have_traps(void) +{ + char *volatile *tp; + + for (tp = trap ; tp <= &trap[NSIG - 1] ; tp++) { + if (*tp && **tp) /* trap not NULL or SIG_IGN */ + return 1; + } + return 0; +} + +/* * Set the signal handler for the specified signal. The routine figures * out what it should be set to. */ Modified: head/bin/sh/trap.h ============================================================================== --- head/bin/sh/trap.h Sat Jun 13 20:58:12 2009 (r194126) +++ head/bin/sh/trap.h Sat Jun 13 21:10:41 2009 (r194127) @@ -39,6 +39,7 @@ extern volatile sig_atomic_t gotwinch; int trapcmd(int, char **); void clear_traps(void); +int have_traps(void); void setsignal(int); void ignoresig(int); void onsig(int); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906132120.n5DLK2pp053617>