Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 studying the Monastery: (11)
As of 2014-09-23 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (221 votes), past polls