aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Cracauer <cracauer@FreeBSD.org>1999-04-01 13:27:36 +0000
committerMartin Cracauer <cracauer@FreeBSD.org>1999-04-01 13:27:36 +0000
commitc1c72a3c2a21f537b989350b1b06b8a44831987a (patch)
tree73e07332230c9dccde976955d509f7c32563b80e
parent29b873f38d2ab9345639df5d707f3df80f9fb5f2 (diff)
downloadsrc-c1c72a3c2a21f537b989350b1b06b8a44831987a.tar.gz
src-c1c72a3c2a21f537b989350b1b06b8a44831987a.zip
The immediate execution of traps I introduced in September 1998 (to
make /etc/rc interruptible in cases when programs hang with blocked signals) isn't standard enough. It is now switched off by default and a new switch -T enables it. You should update /etc/rc to the version I'm about to commit in a few minutes to keep it interruptible.
Notes
Notes: svn path=/head/; revision=45221
-rw-r--r--bin/sh/eval.c5
-rw-r--r--bin/sh/options.h6
-rw-r--r--bin/sh/sh.114
-rw-r--r--bin/sh/trap.c5
4 files changed, 23 insertions, 7 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 427b2bca51d7..8b4fb62fba22 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: eval.c,v 1.15 1998/05/18 06:43:34 charnier Exp $";
#endif /* not lint */
#include <signal.h>
@@ -706,7 +706,8 @@ evalcommand(cmd, flags, backcmd)
/* Fork off a child process if necessary. */
if (cmd->ncmd.backgnd
- || (cmdentry.cmdtype == CMDNORMAL && (flags & EV_EXIT) == 0)
+ || (cmdentry.cmdtype == CMDNORMAL
+ && ((flags & EV_EXIT) == 0 || Tflag))
|| ((flags & EV_BACKCMD) != 0
&& (cmdentry.cmdtype != CMDBUILTIN
|| cmdentry.u.index == DOTCMD
diff --git a/bin/sh/options.h b/bin/sh/options.h
index 28b98192d7aa..907cab2a4645 100644
--- a/bin/sh/options.h
+++ b/bin/sh/options.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)options.h 8.2 (Berkeley) 5/4/95
- * $Id$
+ * $Id: options.h,v 1.7 1997/02/22 13:58:40 peter Exp $
*/
struct shparam {
@@ -64,8 +64,9 @@ struct shparam {
#define bflag optlist[13].val
#define uflag optlist[14].val
#define privileged optlist[15].val
+#define Tflag optlist[16].val
-#define NOPTS 16
+#define NOPTS 17
struct optent {
const char *name;
@@ -91,6 +92,7 @@ struct optent optlist[NOPTS] = {
{ "notify", 'b', 0 },
{ "nounset", 'u', 0 },
{ "privileged", 'p', 0 },
+ { "trapsasync", 'T', 0 },
};
#else
extern struct optent optlist[NOPTS];
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index 61b8aff6ed5e..d55b9dfc2acb 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
-.\" $Id: sh.1,v 1.23 1998/12/18 03:51:18 jkoshy Exp $
+.\" $Id: sh.1,v 1.24 1999/03/31 21:02:01 brian Exp $
.\"
.Dd May 5, 1995
.Dt SH 1
@@ -202,12 +202,24 @@ after
and ignores the contents of the
.Ev ENV
variable.
+
.It Fl s Li stdin
Read commands from standard input (set automatically
if no file arguments are present). This option has
no effect when set after the shell has already started
running (i.e. with
.Xr set 1 Ns ).
+.It Fl T Li asynctraps
+When waiting for a child, execute traps immediately. If this option is
+not set, traps are executed after the child exits, as specified in
+.St -p1003.2
+This nonstandard option is useful to put guarding shells around childs
+that block signals. The surrounding shell may kill the child or it may
+just return control to the tty and leave the child alone, like this:
+.Bd -literal -offset indent
+sh -T -c "trap 'exit 1' 2 ; some-blocking-program"
+.Ed
+.Pp
.It Fl u Li nounset
Write a message to standard error when attempting
to expand a variable that is not set, and if the
diff --git a/bin/sh/trap.c b/bin/sh/trap.c
index fd359fc6d97a..429253c2d53b 100644
--- a/bin/sh/trap.c
+++ b/bin/sh/trap.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
#endif
static const char rcsid[] =
- "$Id: trap.c,v 1.16 1998/09/10 14:51:06 cracauer Exp $";
+ "$Id: trap.c,v 1.17 1998/09/10 22:09:11 cracauer Exp $";
#endif /* not lint */
#include <signal.h>
@@ -367,7 +367,8 @@ onsig(signo)
* If a trap is set, not ignored and not the null command, we need
* to make sure traps are executed even when a child blocks signals.
*/
- if (trap[signo] != NULL &&
+ if (Tflag &&
+ trap[signo] != NULL &&
! trap[signo][0] == '\0' &&
! (trap[signo][0] == ':' && trap[signo][1] == '\0'))
breakwaitcmd = 1;