w3ntp has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use fork to run a process in the background while the parent process continues running its own code. What I have is:
Neils Program:
#!/usr/local/bin/perl # some code if ($pid = fork ) { print "this is the parent\n"; } else { print "this is the child\n"; exec `some unix command that does not terminate`; } # more of Neils code exit;
It is my goal to run neil's program, kick off the unix command in background mode then continue running more of Neil's code. When I run this program and do a ps -ef on my solaris 9 machine I get:
What I want to happen is if I do a ps -ef, then I should get one copy of Neil's main program and one copy of Neil's child process. Furthermore, if I kill Neil's Main program, the child should die. I have tried the examples of fork in the Perl Cookbook with similar results.
Finally, the reason that I do not use a pipe to an open statement is that using this process prevents my child process from communicating to its license server. So I am trying a different approach using fork.
thanks for any suggestions
W3NTP
neil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to run a process in background mode
by flyingmoose (Priest) on Mar 24, 2004 at 22:05 UTC | |
by w3ntp (Beadle) on Mar 29, 2004 at 20:29 UTC | |
|
Re: how to run a process in background mode
by halley (Prior) on Mar 24, 2004 at 21:12 UTC | |
|
Re: how to run a process in background mode
by Vautrin (Hermit) on Mar 24, 2004 at 20:53 UTC | |
by w3ntp (Beadle) on Mar 29, 2004 at 20:31 UTC |