Odd shell behaviour

From: Alain G. (agrumela_at_nospamfoxboro.ca)
Date: 09/01/04


Date: Tue, 31 Aug 2004 21:07:32 -0400

I have used the following shell sequence without any problems
on a number of application running on Solaris 5.

    #! /bin/sh

    sleep 999 & pid=$!
    myprogr-syncpid $pid &
    wait $pid

The idea is to suspend execution of the shell script until
myprog has finished its initialization.
myprog kills the sleep process using the $pid argument when
it is ready and wait unblocks.

I recently tried to use the same scheme on Solaris 8 and found
it fails occasionally (not always).
The shell does not suspend on wait and sleep lives on until the time
expires.
As far as I can tell, this fails because $! returns the pid of a sub-shell
rather
than the pid of the sleep process.

The sh man pages says that the the shell will execute a command in a
sub-shell
if the command's executable file is not an a.out type of file.
Yet when I check "which sleep" I find that it is /usr/bin/sleep and
file /usr/bin/sleep reports that it is a regular executable file for that
platform
which I believe is the same as an a.out file.

Is there anyone who can offer any explanation why this is happenning?

Thanks

AL.



Relevant Pages

  • Odd shell behaviour
    ... I have used the following shell sequence without any problems ... The idea is to suspend execution of the shell script until ... than the pid of the sleep process. ...
    (comp.unix.solaris)
  • Re: Odd shell behaviour
    ... >> I have used the following shell sequence without any problems ... >> The idea is to suspend execution of the shell script until ... >> The shell does not suspend on wait and sleep lives on until the time ...
    (comp.unix.shell)
  • Re: Mandrake Linux 10.1 Path
    ... Depends on what shell you are running. ... do a ls -1 /etc/profile.d to see order of file execution. ... non-interactive session. ... When you login using the bash shell, the first file to run is ...
    (alt.linux)
  • Re: Securely allowing just one application via telnet
    ... One way is to use a traditional login shell and set the config ... file to pass execution to your application. ... trust your user (he's using telnet, so his password is easy to steal,) ...
    (freebsd-questions)
  • Re: 4NT seems flaky when used from makefile
    ... but only with some extension during execution. ... > Running commands one at a time isn't an issue: ... > make CMD open a secondary shell. ... > My next step is to get on to the developers with a bug report, ...
    (comp.os.msdos.4dos)