Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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 - ie
C:\wrappers\RenderWrap.pl -some args * - output etc * ^C In cleanup.
And so the child process is killed.
#!/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

In reply to Re: Re: Ways and means of killing Win32 processes by submersible_toaster
in thread Ways and means of killing Win32 processes by submersible_toaster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (9)
    As of 2014-07-24 21:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (167 votes), past polls