|
Hi All,
I am facing a problem related to fork-exec-pipe sequence in perl on linux. (perl version 5.8.6 on fedora linux)
I have a piece of perl code on Sun Solaris system(perl version 5.005_03) which is working absolutely fine. However when I tried the same code on fedora linux it does not work.
I am copying the part of the code here:
pipe R1, W1;
pipe R2, W2;
select((select(W2), $| = 1)[0]); # autoflush output to dotcntl
$chld = fork();
if ($chld == 0) {
# Child: execute FORTRAN wrapper.
print("comes in child \n");
close R1;
close W2;
open(STDIN, "<&R2");
open(STDERR, ">&W1");
exec("$PSE_HOME/bin/dotcntl") or
print("PSE:ERROR Optimizations not installed.\n"), exit 2;
} else {
# Parent: interact with the wrapper.
close W1;
close R2;
#do the stuff
}
here I expect to get the parent executed first and then child repeatedly. It works as expected on SunOS however on linux it executes child first - does nothing, then executes parent and for obvious reasons it hangs.
Does anyone have any idea about what's going on here.
Waiting for the reply.
Thanks,
Shubhangi
|