Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^3: Fork exec and not wait?

by kennethk (Abbot)
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):


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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2015-11-30 07:33 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (764 votes), past polls