>Micheal Fowler wrote: >Use fork and exec: > > my $pid = fork(); > die("Unable to fork: \l$!.\n") unless defined($pid); > if ($pid) { > # Get the window title. > } else { > exec($program); > } >It's not guaranteed the child will be ready when then parent is reaches the >code to query the window title. You will likely have to poll for the data >you want, or sync up the parent and child processes.
OK, I'm just learning, so I wanted to try this fork statement. #!/usr/bin/perl use warnings; my $program = 'ls'; my $pid = fork(); die("Unable to fork: \l$!.\n") unless defined($pid); if ($pid) { print "$pid\n"; } else { exec($program); } Now what is confusing me, is the if-else behavior. When I run this program sometimes just the pid is printed, then sometimes the pid AND the ls is printed. The ls is never printed alone. What's happening in the if-else statement that is allowing both to be executed? Is it just accidental timing, that the pid disappears after printing, but before the else statement is evaluated? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]