Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: killing pp exe on windows leaves child running? ( IsParParentAlive ppsimple.pl ppautolink.pl )

by Anonymous Monk
on Sep 01, 2019 at 02:59 UTC ( [id://11105364]=note: print w/replies, xml ) Need Help??


in reply to killing pp exe on windows leaves child running?

Hi

Report this to rt://PAR for PAR::FAQ

TODO/BUG rt://PAR/PAR::FAQ is also missing a copy/mention of ppsimple.pl and ppautolink.pl

BEGIN { my $PAR_PROGNAME = $ENV{PAR_PROGNAME}; use Win32::Process::Info(); my $pi = Win32::Process::Info->new(); my $parentpid = $pi->GetProcInfo( $$, { no_user_info => 1 } )->[0]->{ParentProce +ssId}; my $ExecutablePath = $pi->GetProcInfo( $parentpid, { no_user_info => 1 } )->[0] ->{ExecutablePath}; undef $pi; no Win32::Process::Info; sub IsParParentAlive { ## IsWin32ParParentAlive $PAR_PROGNAME eq $ExecutablePath ## doublecheck ## $ENV{PAR_SPAWNED} ## equivalent statement and kill 0, $parentpid; } } ## end BEGIN

Usage, if parent a.exe got killed, then PAR_SPAWNED a.exe dies hard

while( 1 ){ print " $$ doing stuff\n"; sleep 1; if( not IsParParentAlive() ){ die "ParParent is dead"; } }

https://metacpan.org/source/RSCHUPP/PAR-Packer-1.049/contrib/docs/who_am_i.txt

https://metacpan.org/source/RSCHUPP/PAR-Packer-1.049/contrib/docs/where_is_it.txt

https://perldoc.perl.org/perlport.html#kill

https://metacpan.org/pod/PAR::Environment#PAR_PROGNAME

  • Comment on Re: killing pp exe on windows leaves child running? ( IsParParentAlive ppsimple.pl ppautolink.pl )
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: killing pp exe on windows leaves child running? ( IsParParentAlive P9Y::ProcessTable )
by Anonymous Monk on Sep 01, 2019 at 04:23 UTC

    Portable version using P9Y::ProcessTable ... it works on win32 , probably works on other OS if par works the same there

    BEGIN { my $PAR_PROGNAME = "$ENV{PAR_TEMP}\\$ENV{PAR_ARGV_0}.exe"; ## hack use P9Y::ProcessTable(); my $perl_process = P9Y::ProcessTable->process; my $parentpid = $perl_process->ppid; my $ExecutablePath = $perl_process->{exe}; undef $perl_process ; no P9Y::ProcessTable(); sub IsParParentAlive { ( $PAR_PROGNAME eq $ExecutablePath ## doublecheck or $ENV{PAR_SPAWNED} ) and kill 0, $parentpid; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105364]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found