Your input is appreciated !

José.

> -----Original Message-----
> From: david [mailto:[EMAIL PROTECTED]] 
> Sent: Monday, January 27, 2003 8:16 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Concurrency problem
> 
> 
> Nyimi Jose wrote:
> 
> > 
> > #!/usr/bin/perl -w
> > use strict;
> > use Proc::ProcessTable;
> > use File::Basename;
> > 
> > my $is_running=&a_check_subroutine();
> > sleep (60) if $is_running;#sleep 60 seconds
> > 
> > sub a_check_subroutine{
> > my $script=quotemeta File::Basename::basename($0);
> > my $t = new Proc::ProcessTable;
> > foreach my $p (@{$t->table}){
> > return 1 if $p->cmndline =~ /$script/ ;
> > }
> > return 0;
> > }
> > __END__
> > 
> 
> checking the process table over and over again is very 
> costly. you should
> try to grab the process id that you are tracking and just see if the 
> process is alive once a while. for example, the following 
> checks for the process started in working.pl and waits until 
> it finish:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> use Proc::ProcessTable;
> 
> my ($id,$prg) = (0,'');
> 
> for(@{Proc::ProcessTable->new->table}){
>         if($_->cmndline =~ /working\.pl/){
>                 $id = $_->pid;
>                 $prg = $_->cmndline;
>                 last;
>         }
> }
> 
> die "working.pl is not running\n" unless($id);
> 
> while(kill(0,$id)){
>         sleep(1);
>         print "$prg still running as $id\n";
> }
> 
> print "$prg finished\n";
> 
> __END__
> 
> this way, you don't have to check the process table over and 
> over again 
> which can be slow.
> 
> david
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to