Thursday, September 16, 2004

Background processes in Perl

Problem: i don't know how to set a task as a background process. My code's running on GNU/Linux, btw. I've tried adding an & before the last backticks, but it still waits for the process to end.
What it does is run the external program, so that it's output goes to a file. And i want it to run in the background.
I've tried this:
`$exe_file > $tmp_file &`;

BTW, my program is run by the user in a web browser.
I could see the perl script running by running "ps"
And i know my code works, because simple operations gives the right output.

What i plan to do is to run that binary file as an executable, and make my script check if there's already a file outputed by that binary - by refreshing the page every 5 seconds, using a meta tag (html) - and if there already is a file, it'll read the file and print it to the page.
I checked the documentation (perldoc perlfunc), but found that only "fork" is related to backgrounding - i "grepped" the documentation for "background" and only the fork part has that word.

Any help would be appreciated.

0 Comments:

Post a Comment

<< Home