Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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):

$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 chanting in the Monastery: (3)
As of 2015-07-06 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls