bug-bash
[Top][All Lists]
Advanced

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

Inconsistent behavior between 'wait' and 'builtin wait'


From: Luiz Angelo Daros de Luca
Subject: Inconsistent behavior between 'wait' and 'builtin wait'
Date: Wed, 03 May 2017 00:33:29 +0000

Hello,

Bash was supposed to return 128+signal if a signal is received while
running wait command.
However, the "builtin wait" does not do the same. "builtin wait" simply
ignores that the signal
happened.

This happens at least since version 3.2.57(2)-release
(x86_64-suse-linux-gnu) until 4.4.12(1)-release

#!/bin/bash

trap "true" USR1
(
sleep 1
echo "Signal while wait"
kill -USR1 $$
sleep 1
echo "Signal while builtin wait"
kill -USR1 $$
sleep 1
echo "Normal exiting"
exit 3
) &
_pid=$!
wait
echo $?
builtin wait $_pid
echo $?


$ bash wait_test.bash
Signal while wait
138
Signal while builtin wait
Normal exiting
3

Both waits should return 138? I detected this while trying to replace wait
with a function in order to
ignore when it returned because of a signal (with a very ugly hack). So,
the "builtin wait" behavior
was exactly the one I was trying to implement.

I guess command wait could have an optional argument for both behavior
(exit or ignore on signal).

Is this expected and simply not documented (doc bug), or both wait should
be equal? I just don't want to rely on a
bug behavior that might break in the future.

Regards,
-- 

Luiz Angelo Daros de Luca
address@hidden


reply via email to

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