On 3/13/06, Cornelis Swanepoel <[EMAIL PROTECTED]> wrote: > > I have found the following text in the perlfork manpage: > > Calling exec() within a pseudo-process actually spawns the requested > > executable in a separate process and waits for it to complete before exiting > > with the same exit status as that process. This means that the process ID > > reported within the running executable will be different from what the > > earlier Perl fork() might have returned. > > > > but then from Randal and Tom's Learning Perl(3rd edition) about exec on > p.196: > > When we reach the exec operation, Perl locates bedrock and "jumps into > > it".At that point, there is no Perl process any more*, just the process > > running the bedrock command. > > *Actually, it's the same process, having performed the Unix exec(2) system > > call. The process ID remains the same. > > > > Since the exec'ed process doesn't retain the same PID as what forked > returned, how can my waitpid ever reap the correct child process ? > > I'm trying hard to get my head around this and would really appreciate your > input. > > Cornelis >
Use system() instead of exec(). Actually, most of the time when you're executing system commands, system() is what you're looking for. You'll want exec() to spawn daemons and occasionally set up an execution environment, but if you care at all about the return value of the command (or subprocess that spawned the command), you want system(). HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
