]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - builtins/wait.def
Imported from ../bash-2.04.tar.gz.
[thirdparty/bash.git] / builtins / wait.def
index 11fe85a907d2a15612f3de1419aef42c9a999c0e..2e3fac5776241fd1c000be822b221d000b4f99a8 100644 (file)
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
 
 Bash is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
 version.
 
 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
 
 You should have received a copy of the GNU General Public License along
 with Bash; see the file COPYING.  If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
 
 $BUILTIN wait
 $FUNCTION wait_builtin
@@ -59,6 +59,8 @@ $END
 
 extern int interrupt_immediately;
 
+procenv_t wait_intr_buf;
+
 /* Wait for the pid in LIST to stop or die.  If no arguments are given, then
    wait for all of the active background processes of the shell and return
    0.  If a list of pids or job specs are given, return the exit status of
@@ -70,7 +72,7 @@ int
 wait_builtin (list)
      WORD_LIST *list;
 {
-  int status;
+  int status, code;
 
   if (no_options (list))
     return (EX_USAGE);
@@ -81,6 +83,21 @@ wait_builtin (list)
   unwind_protect_int (interrupt_immediately);
   interrupt_immediately++;
 
+  /* POSIX.2 says:  When the shell is waiting (by means of the wait utility)
+     for asynchronous commands to complete, the reception of a signal for
+     which a trap has been set shall cause the wait utility to return
+     immediately with an exit status greater than 128, after which the trap
+     associated with the signal shall be taken.
+
+     We handle SIGINT here; it's the only one that needs to be treated
+     specially (I think), since it's handled specially in {no,}jobs.c. */
+  code = setjmp (wait_intr_buf);
+  if (code)
+    {
+      status = 128 + SIGINT;
+      WAIT_RETURN (status);
+    }
+
   /* We support jobs or pids.
      wait <pid-or-job> [pid-or-job ...] */