Re: Odd shell behaviour

From: Mark R.Bannister (Chapter33_at_aol.com)
Date: 09/02/04


Date: 2 Sep 2004 09:50:35 -0700


"Alain G." <agrumela@nospamfoxboro.ca> wrote in message news:<Ng9Zc.10204$7i2.610426@news20.bellglobal.com>...
> 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.

I've tried a dozen

sleep 1 & pid=$! && wait $pid

on Solaris 8 and haven't experienced your problem. Can you email me a truss?

Regards,
Mark.



Relevant Pages

  • Re: pid from startet process
    ... perl script and need to know the childs pid. ... but the pid i am getting is not right. ... That shell then creates a new process to ... execute the command named in the $cmd parameter. ...
    (comp.lang.perl.misc)
  • Re: External Unix programme - time limit
    ... checking if the process is still active after the sleep. ... >> kill the right programme...and when using the syntax you ... > You don't need to know the PID, %1 is the first job running in the ... > shell, which should be your ./senkin.e program. ...
    (comp.soft-sys.matlab)
  • Re: PID of exec
    ... but it contained the same PID as the "my $pid=fork" statment. ... noticed that you tried to write the pid out after the exec. ... array with one element in it, the argument is checked for shell ... If there are no shell metacharacters in the argument, ...
    (comp.lang.perl.misc)
  • Re: How do I tell "sh" to automatically switch to bash
    ... statically linked shell which will not be dependent on the dynamic ... Solaris, when properly configured, ... for root or any other account. ... interact with production boxes at work all day long but I also ...
    (comp.unix.solaris)
  • Re: Backspace
    ... But actually I'm using Bourne shell on FreeBSD 6.1 just like the ... Solaris in lab, and the FreeBSD is freshly installed, I have checked ... I think Solaris was just like the above. ... shells in UNIX environments have startup files to customize the key ...
    (freebsd-questions)