in reply to Re: exec sometimes changes pid
in thread exec sometimes changes pid

Assuming that the pid returned from fork is the shell's, then why not do the opposite? Set SIGHUP to 'DEFAULT' then kill the shell. Assuming that the shell command is not doing something like 'nohup', then that should kill the shell's child, without needing `ps`.

Replies are listed 'Best First'.
Re^3: exec sometimes changes pid
by doom (Deacon) on Aug 04, 2009 at 12:43 UTC

    If killing the pid for the intermediate shell Just Worked, then I wouldn't be asking this question. I must say I don't understand why it doesn't work...

    It didn't occur to me to explicitly set SIGHUP to 'DEFAULT', maybe that would've made a difference.