Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Fork exec and not wait?

by kennethk (Monsignor)
on Jan 24, 2013 at 20:06 UTC ( #1015226=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Fork exec and not wait?
in thread Fork exec and not wait?

Is there anyway to either fork a process and force its output to /dev/null or simply make the parent ignore the child and continue?

You can literally accomplish this task by redirecting your STDOUT and STDERR to /dev/null using open in the child after your fork:

open STDOUT, '>', '/dev/null' or die "Redirect failed: $!"; open STDERR, '>', '/dev/null' or die "Redirect failed: $!";

You'd probably combine this in an instruction to not bother waiting to reap the child (see perlipc):

$SIG{CHLD} = "IGNORE";

However, you are treating a symptom here.As eyepopslikeamosquito says, this sounds like an XY Problem. I suspect your dissection of the system is incorrect, and what's actually happening is your child is hanging on STDIN that's not coming. Post code so we can actually diagnose this and fix it.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re^3: Fork exec and not wait?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2014-07-11 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (235 votes), past polls