in reply to Re: Re: system() call failure
in thread system() call failure

system() does a wait() for the /bin/ls process to complete. When the process ends, your handler jumps in and grabs it, and system() gets nothing, which isn't what it wanted. If you run a command that has a side effect, you should see that it actually does get executed.

It's interesting that it worked on Linux but not Solaris. Must be some difference in the way they deliver signals.

Best solution is probably not to mix $SIG{CHLD} with system(). There are a couple of threads around here that might be useful... try a search or two.

Replies are listed 'Best First'.
Re: Re: Re: Re: system() call failure
by lestrrat (Deacon) on May 15, 2001 at 21:10 UTC

    I ended up overloading the system() function call with my version of it. The truth is *I* don't need system(), but other people using my framework do. So I need account for this

    anyway, all I did was to make sure that the $SIG{'CHLD'} gets masked by local $SIG{'CHLD'} = <em>blah</em>, and the rest is just your typical fork()/exec()

    Boy, that was annoying! Thanks to both clintp and no_slogan for your help :-)

Re: Re: Re: Re: system() call failure
by lestrrat (Deacon) on May 16, 2001 at 23:02 UTC

    just letting you guys know what happened... So it turns out yes, you must be correct: when system() forks, for some reason the $SIG{ 'CHLD' } that I defined gets called.

    I don't really need to call system(), but others who use my code do, so I decided on just overloading the system() function call with a version that uses a local $SIG{ 'CHLD' }

    It works now :-)

    Thanks for your help..