|We don't bite newbies here... much|
exec sometimes changes pidby doom (Deacon)
|on Aug 02, 2009 at 21:54 UTC||Need Help??|
doom has asked for the wisdom of the Perl Monks concerning the following question:
I sometimes use the idiom where you fork off a child process, and then have the child exec to run some other code, and then later have the parent kill the child's pid to get rid of it. I've seen some odd behavior on one of my machines, though, where the "exec" changes the pid of the child, so the return from fork is no longer the pid that I need to kill. The following code runs differently on my workstation and my laptop, despite the fact that they're both AMD64 machines running ubuntu jaunty, using perl 5.10.0:
On the laptop, the child pid stays the same after the exec, but on the workstation it increases by one. There's very little difference between the two machines... the laptop is a single-processor (Turion) and the workstation is a dual (a dual-Opteron).
They are running slightly different kernel versions, though, the workstation is "2.6.24-16-generic" and the laptop is "2.6.27-9-generic".
Any ideas what this might be about? If you've got a minute, could you please run the code I posted above and report back on how it behaves for you?
On my workstation (the dual-Opteron) the results are something like this:
On my laptop (the Turion) the reults are like so: