git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] perl: redirect stderr to /dev/null instead of closing

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 5, 2013, 18:57 UTC
Message-ID
<7vsj34byb4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130405144828.GX6137@machine.or.cz>
Petr Baudis <pasky@ucw.cz> writes:
Show 14 quoted lines
>> >  		} elsif ($pid == 0) {
>> > -			if (defined $opts{STDERR}) {
>> > -				close STDERR;
>> > -			}
>> >  			if ($opts{STDERR}) {
>> >  				open (STDERR, '>&', $opts{STDERR})
>> >					or die "dup failed: $!";
>> 
>> Indeed.  Thanks for pointing that out.
>
>   I'm sorry, I don't follow. Doesn't this just break the STDERR option
> altogether as we will try to dup2() over an already open file
> descriptor? We do need to close STDERR if we are going to reopen it,
> I think.

When $opts{STDERR} is 2, what the three lines the proposed patch removes did is actively wrong, because you dup2 the fd you just closed.

When $opts{STDERR} is 1, it seems to do the right thing with or without the "close STDERR" in front. Isn't this because the usual "open($fd, <<<anything>>>) closes $fd as necessary" applies to this case as well?

So, I am not sure what you are viewing as a problem.  Puzzled...
Previous: Petr BaudisNext: Petr Baudis
Message 6 of 11 in “perl: redirect stderr to /dev/null instead of closing”
  1. perl: redirect stderr to /dev/null instead of closingThomas Rast, Apr 3, 2013
  2. Eric WongApr 4, 2013
  3. 1/2 perl: redirect stderr to /dev/null instead of closingThomas Rast, Apr 4, 2013
  4. Eric WongApr 4, 2013
  5. Petr BaudisApr 5, 2013
  6. Junio C HamanoApr 5, 2013
  7. Petr BaudisApr 5, 2013
  8. Thomas RastApr 6, 2013
  9. Petr BaudisApr 6, 2013
  10. 2/2 t9700: do not close STDERRThomas Rast, Apr 4, 2013
  11. Jonathan NiederApr 4, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.