Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

•Re: close STDOUT and system equal strange?

by merlyn (Sage)
on Feb 21, 2004 at 23:22 UTC ( #330862=note: print w/replies, xml ) Need Help??


in reply to close STDOUT and system equal strange?

You're trying to pull a fast one on the kernel, and you lost. "standard output" is file descriptor 1. When you open a new file, it goes to the lowest unopened file descriptor. Normally, 0, 1, and 2 are all busy being standard input/output/error, but by closing STDOUT, you left room for another file to be fd 1. Hence, you lose. If you don't want that behavior, don't do that.

If you want to ensure that the child's standard output goes nowhere, open STDOUT onto /dev/null instead.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re: close STDOUT and system equal strange?

Replies are listed 'Best First'.
(jptxs) Re: close STDOUT and system equal strange?
by jptxs (Curate) on Feb 22, 2004 at 01:10 UTC

    For the record, I wasn't trying =]

    I was happy to see it in the file in the larger program where I saw this happen b/c I had been planning on redirecting it there anyway. I suppose I could leave it this way, but I probably will not. It seems like a "bad way to do it".

    thanks for the enlightenment, merlyn.

    We speak the way we breathe. --Fugazi
File::Spec->devnull();
by Anonymous Monk on Feb 22, 2004 at 08:54 UTC
    or File::Spec->devnull();

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://330862]
help
Chatterbox?
[Corion]: I hope you had a good weekend!
[marto]: jetlag has really done a number on the kids, it's been a tough week
choroba played with the band on Saturday, so Sunday was very sleepy
[choroba]: managed to release Syntax::Construct with 5.28 support in the night, though
[Corion]: choroba: Whee ;)
[Corion]: marto: Ouch - I would've thought that kids adapt much better, but that's obviously not the case...
[marto]: well, their mother let them sleep till 15:00 & 12:00 last week, which didn't help them adjust :P
[Corion]: I was "productive" over the weekend in the sense that I revived my old "Perlmonks on SQLite" code, which likely means I can get a test instance back up running on my webhost. Small steps :)
[Corion]: marto: Ow, no, that doesn't help at all :)

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2018-06-25 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?