rehmanz has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to spawn an xterm window that does a "tail -f" to a summary log file. However the pid is not the correct one! When my script tries to kill the window, the $pid does not has the right process Id. Can someone please help? I have attached my code! Thanks in advance PerlMonks!
#!/usr/bin/perl my $fname = "/tmp/help.txt"; system("echo help me > $fname"); my $pid = fork(); if ($pid eq 0) { sleep (1); system ("xterm -T hello -e tail -f $fname &"); exit(-1); } print "This is not the correct pid: $pid \n"; sleep(5); print "After some point in time, I want to kill $pid! \n"); system ("kill -9 $pid"); print "$pid is incorrect!\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl fork pid Not Correcto for Xterm Spawn
by ikegami (Patriarch) on Jul 08, 2010 at 00:09 UTC |