Re: Time based processes

2012-07-25 Thread punit jain
Hi Below is my script where alarm is generated after 15 sec and changes the global variable in parent from 0 to 1. Is there any mistake in my multiprocess approach with time-based stop ? #!/usr/bin/perl use strict; use warnings; use Parallel::ForkManager; my $MAX_PROC=2; $|++; my $stopFlag=0; m

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 19:16, punit jain wrote: for my $step ( @steps ) { last if $STOP; I would think the issue here is if the list is 30K long and we are still at 2K why would be really like to process whole list ? We can die or handle exit of the script gracefully in my understanding. Is my und

Re: Time based processes

2012-07-21 Thread punit jain
> > > for my $step ( @steps ) { >last if $STOP; > > > I would think the issue here is if the list is 30K long and we are still > at 2K why would be really like to process whole list ? > We can die or handle exit of the script gracefully in my understanding. > > Is my understanding correct here

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 16:20, Dr.Ruud wrote: On 2012-07-21 15:41, punit jain wrote: You can let the ALRM-sub simply set a global variable, like $STOP. Your process should check this before starting a next iteration. I suppose this needs to be set in parent process which means Signal needs to be invok

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 15:41, punit jain wrote: You can let the ALRM-sub simply set a global variable, like $STOP. Your process should check this before starting a next iteration. I suppose this needs to be set in parent process which means Signal needs to be invoked in parent. Is my understanding corr

Re: Time based processes

2012-07-21 Thread punit jain
Also for :- > for my $step ( @steps ) { last if $STOP; I would think the issue here is if the list is 30K long and we are still at 2K why would be really like to process whole list ? We can die or handle exit of the script gracefully in my understanding.

Re: Time based processes

2012-07-21 Thread punit jain
For the case which you mentioned :- >You can let the ALRM-sub simply set a global variable, like $STOP. Your process should check this before starting a next iteration. I suppose this needs to be set in parent process which means Signal needs to be invoked in parent. Is my understanding correct ?

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 15:30, Dr.Ruud wrote: On 2012-07-21 14:50, punit jain wrote: *(B) How do I stop the script graceful without killing the processes and stop from other sunbprocesses being spanned ?* Just let $SIG{INT} and $SIG{TRM} also set $STOP. s/TRM/TERM/ See `kill -l` for the names. Pe

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 14:50, punit jain wrote: *(B) How do I stop the script graceful without killing the processes and stop from other sunbprocesses being spanned ?* Just let $SIG{INT} and $SIG{TRM} also set $STOP. Per child you can update $0, to be able to watch the status of the process in ps.

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 14:50, punit jain wrote: I have a requirement where I need to run my perl script for x hours You can let the ALRM-sub simply set a global variable, like $STOP. Your process should check this before starting a next iteration. Beware that each child needs its own alarm. The parent