Subject: Bourne shell oddity
To: None <>
From: Havard Eidnes <>
List: current-users
Date: 06/21/2005 16:35:10

I have noticed an oddity with our bourne shell.  This is
illustrated with the following two small scripts.  Place them in
/tmp and make /tmp/x executable to reproduce:

-------------------- /tmp/x:
#! /bin/sh

echo x: before
( sh -c "sleep 60" ) > /dev/null 2>&1 </dev/null &
echo x: after
exit 0
-------------------- /tmp/y:
#! /bin/sh

echo y: before


echo y: after

If you run "sh /tmp/y", the "y: after" output will not appear
until 60 seconds has passed, i.e. the innermost background job
finishes, even though that job has no chance of affecting the
result due to the redirection.

If the 'sh -c "sleep 60"' is not done inside a subshell, this
does not happen, i.e. the /tmp/y script would finish right away.

If the /tmp/x script is changed to a /bin/ksh or a bash script,
this also does not happen, i.e. /tmp/y finishes right away and
does not hang around for the backgrounded sleep job to finish.

This smells like a bug in our Bourne shell implementation.  Is
that correct?


- Havard