how to kill a forked child-process in perl
hi,
can any one help me to with this problem , my $pid=fork(); die "Cannot fork: \n" if (! defined $pid); if (! $pid) { # Only the child does this $sys = system("/usr/bin/firefox localhost:8066 >/dev/null"); if($sys!='0'){ print RED, "Sorry the web page could not be loaded" , RESET; exit(0); } } when i execute the above snippet of code , the program displays, print statement and gets hanged m without returning my terminal, help plsssssss regards, ice_man --------------------------------------------------------------- FREE as in FREEDOM thats LIFE |
You realize, don't you, that the exit(0) applies only to the child process and not to the parent?
|
ok, but now how to overcome this problem, where should , i put th eexit statement,
thanks in advance ______________________________________________________ FREE as in FREEDOM thats LIFE |
After the main if(), ie where the parent code will go on successful fork()
|
sorry id did not work , i tried using wxit after the main if() block , but it was vain , any suggestiond ,please
_________________________________________ FREE as in FREEDOM thats LIFE |
Try writing a simple Perl script whose only job is to fork. Put a print statement in the child code saying "running the child code", and print also the current pid. Put another print statement in the parent code saying "running the parent code", and print also the current pid.
The pid is stored in special variable [BOLD]$$[/BOLD] Then run the program. If it does what you expect, then see how it differs from the program which is troubling you. If it doesn't do what you expect, post that tiny program here (the entire tiny program). |
All times are GMT -5. The time now is 11:18 PM. |