CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [aclhkaclhk] fork a process: Edit Log



1arryb
User

Apr 29, 2009, 1:26 PM


Views: 564
Re: [aclhkaclhk] fork a process

Hi aclhkaclhk,

Don't use completed.txt; loop on waitpid() in the parent after the fork(), sleeping a few seconds between calls. If you're still "wait"ing after 5 minutes, you can kill your child process (since you know it's pid from the return from fork(). Check out recipe 16.2 from the O'Rielly Perl Cookbook (link to pirate copy deleted) (pdf) or read the perlfork perldoc. Be advised that if this is production code, there are plenty of error cases to handle (e.g., restart-after-failure, double-start, race conditions, etc., etc.).

BTW, this seems like something that should have been wrapped into a module long ago. Anyone out there know of a lightweight asynchronous dispatch package? My short search came up dry.

Cheers,

Larry


(This post was edited by 1arryb on Apr 29, 2009, 1:48 PM)


Edit Log:
Post edited by 1arryb (User) on Apr 29, 2009, 1:48 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives