Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Test::Cmd and forking

by DrWhy (Chaplain)
on Jul 13, 2004 at 15:30 UTC ( #374034=note: print w/replies, xml ) Need Help??


in reply to Test::Cmd and forking

I ran into a similar problem myself in my own test code where I didn't want some END blocks to get executed in the child. There are several possibilities to avoid cleanup code when a forked child exits. I thought of a couple (I bet there's more than two ways to do this though). I'm not really satisfied with either of these though.

  1. Rather than exit or die in the child, exec something innocuous, e.g.:

    exec('/bin/true') or exec('perl','-e','')

  2. Another possibility which I thought of but did not test is to have the child send itself a SIGKILL (or maybe a SIGTERM) would be enough?)

Replies are listed 'Best First'.
Re^2: Test::Cmd and forking
by fergal (Chaplain) on Jul 13, 2004 at 21:45 UTC
    You can use Manip::END to selectively delete END blocks. It was written precisely for your situation where you have a fork and a troublesome END block.
    $ends = Manip::END->new; # now remove some END blocks $ends->remove_class("Test::Cmd"); # only those in Test::Cmd $ends->remove_isa("Test::Cmd"); # in Test::Cmd and any subclasses $ends->remove_pat('^Test::Cmd(::.*)?$'); # any END blocks from Test::C +md and Test::Cmd::Whatever
    You can also do other manipulations.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2020-11-30 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?