Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

STDERR with fork();

by c (Hermit)
on Apr 16, 2002 at 16:26 UTC ( #159553=perlquestion: print w/replies, xml ) Need Help??

c has asked for the wisdom of the Perl Monks concerning the following question:

I was just reading over merlyn's article in SysAdmin this month, and one comment he made is very timely in my scripting life at the moment. In his utility he documents in his article, he touches on forking processes off to speed up a script that is hampered by the timeout due to the nature of icmp.

One line in the article really bent my noodle, so I'm asking the monstery to help clear the fog. Near the bottom of the first page of his article, merlyn states:

"Perl needs to fork a shell because we needed that child to have its standard error output redirected."

Are there problems writing to STDERR from with a fork() process? Or is it just that he is counting on the STDERR output being read and handled by the shell? Maybe I am way off base, but its a very appropriate read since I myself am just getting ready to change the log output in one of my scripts from STDOUT to STDERR.

Thanks -c

Replies are listed 'Best First'.
Re: STDERR with fork();
by Fletch (Chancellor) on Apr 16, 2002 at 16:33 UTC

    It has to fork a shell because he's using shell syntax (that `2>/dev/null' bit) to toss the ping's error output. If he wasn't using backticks and was manually doing a fork/exec, he could have reopened STDERR on /dev/null inside perl.

    Of course he could have used POE::Component::Ping and not even bothered with the backticks. :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2021-06-23 17:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (121 votes). Check out past polls.

    Notices?