ybnormal has asked for the wisdom of the Perl Monks concerning the following question:
Now the problem is when parent process is done or exited, how can I let child process know so that it can exit as well ? And in the first place, I'm not even sure if this is a good way to count the time in parallel with other tasks. In the above code, the first while loop is stopped until some key is typed in, so that I cannot count the run time in that loop, and the best I came up with is having a child process counting the time and displaying it separate from main(parent) process. If there are any better ways, I'd appreciate your suggestion.if($pid=fork){ while($c = ReadKey){ doing something... ; } } else { my $count = 0; while(1){ sleep(1); print $count++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parent process finished. How to exit the child process.
by spazm (Monk) on May 07, 2010 at 04:29 UTC | |
|
Re: Parent process finished. How to exit the child process.
by BrowserUk (Patriarch) on May 07, 2010 at 04:49 UTC | |
|
Re: Parent process finished. How to exit the child process.
by Marshall (Canon) on May 07, 2010 at 10:19 UTC | |
|
Re: Parent process finished. How to exit the child process.
by rovf (Priest) on May 07, 2010 at 07:27 UTC | |
by ybnormal (Novice) on May 07, 2010 at 11:20 UTC | |
by rovf (Priest) on May 10, 2010 at 09:32 UTC | |
|
Re: Parent process finished. How to exit the child process.
by johngg (Canon) on May 07, 2010 at 11:03 UTC |