problem with fork & wait
From: T.S. Ravi Shankar (Ravi.Shankar_at_synopsys.COM)
Date: 03/29/04
- Next message: Smoot Carl-Mitchell: "Re: Incrementing count"
- Previous message: Smoot Carl-Mitchell: "Re: string change problem"
- Next in thread: Bob Showalter: "RE: problem with fork & wait"
- Maybe reply: Bob Showalter: "RE: problem with fork & wait"
- Reply: Smoot Carl-Mitchell: "Re: problem with fork & wait"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Mar 2004 18:38:48 +0530 To: beginners@perl.org
Hi,
At reaching a certain point in my perl program, I need to run a process
( say XYZ ) using SYSTEM command. The result file that this process
would produce will be result.<process_id>. I will have to wait until
this result file is produced & then proceed extracting certain things
from this file.
I am implementing this as :
foreach $check (@run) {
$pid=fork;
if($pid == 0) {
exec("XYZ -a $check");
}else{
$pid1=wait;
}
if ( -e "result.$pid1") {
## perform operations on the file result.$pid1##
}
system("rm result.$pid1");
}
This seems to be performing inconsistently. I am seeing this working
properly sometimes & not working properly sometimes. This works on
certain workstations & doesn't work on certain workstations.
Why is this inconsistency ??
I would be satisfied if I am given a clean/consistent/straight forward
implementation methodology for my purpose.
Thanks,
Ravi
- Next message: Smoot Carl-Mitchell: "Re: Incrementing count"
- Previous message: Smoot Carl-Mitchell: "Re: string change problem"
- Next in thread: Bob Showalter: "RE: problem with fork & wait"
- Maybe reply: Bob Showalter: "RE: problem with fork & wait"
- Reply: Smoot Carl-Mitchell: "Re: problem with fork & wait"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]