Thanks Guys,

It looks like I need SIGCHLD & a little bit of waitpid,

Regards

Marty

> -----Original Message-----
> From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday 10 April 2002 13:59
> To: Martin Moss
> Cc: Perl-Unix-Users
> Subject: Re: [Perl-unix-users] Hard Total amount of Forks
>
>
> Martin Moss wrote:
>
> > All,
> >
> > I wish to add forking to a script I wrote.
> > However I wish to ensure that only a configurable number of
> 'children' are
> > created.
> >
> > forking is no problem,
> > Queuing up things to be forked I can do,
> >
> > However is there an easy way to create a hard total, I was
> thinking the only
> > way is to have each fork write it's pid to a file, and delete it when it
> > dies, and the main parent simply counts the number of pid files in a
> > directory. if The Number is reached the parent may check with a
> kill=>1 on
> > each pid file just to check for non existing processes or
> possibly kill -9'd
> > processes.
> >
> > Or can I do it all in memory and have the parent control, maybe using
> > signals?
> >
> > Has anybody done something simillar, can anybody suggest other methods?
>
>
> What's the big deal ?  You get the pid back after each fork, just store
> it in an array and you can keep track of how many you have forked.
>
> Use waitpid to reap the children periodically (with WNOHANG unless the
> parent has nothing else to do).
>
> --
>    ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
>   (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
>    / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
> -/-' /___/_<_</_</_     Castle of Medieval Myth & Magic
http://www.todbe.com/

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to