bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistent behavior between 'wait' and 'builtin wait'


From: Eduardo Bustamante
Subject: Re: Inconsistent behavior between 'wait' and 'builtin wait'
Date: Wed, 3 May 2017 08:39:10 -0500

On Wed, May 3, 2017 at 8:27 AM, Chet Ramey <chet.ramey@case.edu> wrote:
> Both waits should return the same exit status. Using `builtin' should not
> conceal that aspect of wait's behavior.

FWIW, I can reproduce this in the latest devel branch:

dualbus@debian:~/src/gnu/bash$ ./bash -c 'trap : TERM; { sleep 1; kill
$$; } & wait'
here
143
dualbus@debian:~/src/gnu/bash$ ./bash -c 'trap : USR1; { sleep 1; kill
-USR1 $$; } & builtin wait'
here
^C
dualbus@debian:~/src/gnu/bash$ ./bash -c 'trap : USR1; { sleep 1; kill
-USR1 $$; } & wait $!'
here
138
dualbus@debian:~/src/gnu/bash$ ./bash -c 'trap : USR1; { sleep 1; kill
-USR1 $$; } & builtin wait $!'
here

`wait' vs `builtin wait' do not seem to be following the same code
paths. BTW, the second case (builtin wait with no pid list to wait for
causes an infinite loop here)

The prints are due to:

dualbus@debian:~/src/gnu/bash$ git diff -- builtins
diff --git a/builtins/wait.def b/builtins/wait.def
index 5deb3735..1999c8e7 100644
--- a/builtins/wait.def
+++ b/builtins/wait.def
@@ -67,6 +67,7 @@ $END
 #endif

 #include <chartypes.h>
+#include <stdio.h>

 #include "../bashansi.h"

@@ -132,6 +133,7 @@ wait_builtin (list)
   interrupt_immediately++;
 #endif

+  fprintf(stderr, "here\n");
   /* 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
@@ -147,6 +149,7 @@ wait_builtin (list)
     {
       last_command_exit_signal = wait_signal_received;
       status = 128 + wait_signal_received;
+      fprintf(stderr, "%d\n", status);
       wait_sigint_cleanup ();
       WAIT_RETURN (status);
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]