in reply to Re: Ways and means of killing Win32 processes
in thread Ways and means of killing Win32 processes
A few clarifications
NORMALLY: Smedge2 --executes--> Render.exe MY-WRAPPED VERSION: Smedge2 --executes--> RenderWrap.pl --executes--> Render.exe
The problem being that when smedge2 decides that it should abort a job, it kills the process it executed, this would be fine if there was only one process (NORMALLY) , but MY-WRAPPED has smedge executing the wrapper, sadly when smedge kills 'RenderWrap.pl', the children of 'RenderWrap.pl' do not die. Moreover, no amount of signal trapping will catch the kill issued by smedge. Indeed it seems very similar to the Taskmanager->EndProcess.
Now the code, some of which is show below , does work when given a SIGINT from the commandline - ieAnd so the child process is killed.C:\wrappers\RenderWrap.pl -some args * - output etc * ^C In cleanup.
#!/usr/bin/perl -w $|++; open ( LOG , '>>c:\temp\wrapper.log' ); # debug print LOG "#"x40, $/; print LOG "PID : $$" , $/; print LOG join (',' , @ARGV) , $/; my $mayabatch = 'mayabatch'; $SIG{TERM}=\&cleanup; $SIG{KILL}=\&cleanup; $SIG{INT}=\&cleanup; $SIG{ABRT}=\&cleanup; $SIG{BREAK}=\&cleanup; $SIG{STOP}=\&cleanup; $SIG{QUIT}=\&cleanup; my %o; $o{-file} = shift @ARGV; my @args = @ARGV; while ( @args ) { my $arg = shift @args; if ($arg =~ /-ses/) { $o{-s} = shift @args; $o{-e} = shift @args; $o{-b} = shift @args; } elsif ( $arg =~ /^-/ ) { $o{$arg}=shift @args; } else { warn "Unhandled arg $arg \n"; } } # blah blah, operations on args to wrap # neatly. # my $child = open ( RENDER , "$command |" ) or die "Screaming $!$?\n"; while (<RENDER>) { print }; print "Child exit status was $?" , $/; exit $?; sub cleanup { warn "In cleanup. \n"; kill "HUP" , $child; }
I can't believe it's not psellchecked
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Ways and means of killing Win32 processes
by BrowserUk (Patriarch) on Feb 03, 2003 at 06:44 UTC |
In Section
Seekers of Perl Wisdom