Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Mar 2017 16:19:47 -0800 (PST)
From:      Don Lewis <truckman@FreeBSD.org>
To:        dteske@freebsd.org
Cc:        alfred@freebsd.org, julian@elischer.org, freebsd-current@freebsd.org
Subject:   Re: I/O semantics of pipe and FIFO.
Message-ID:  <201703090019.v290Jlpk004822@gw.catspoiler.org>
In-Reply-To: <B71629F9-A171-4E01-BA0A-39F74C77724B@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On  8 Mar, Devin Teske wrote:
> Problem we had found was:
> 
> Executing dd with a closed stdout and stderr would cause the summary
> messages printed at the end to go into the destination output file.
> 
> For example,
> 
> dd if=/dev/zero of=/tmp/foo bs=1m count=1
> 
> Works fine, but the following:
> 
> dd if=/dev/zero of=/tmp/foo bs=1m count=1 >&- 2>&-
> 
> Will cause the summary statistics of dd to appear in /tmp/foo instead
> of on the console.
> 
> The issue is that the summary statistics are send to fd1, which if you
> close down stdout and stdin, fd1 is actually the output file since it
> got the lowest file descriptor available when open(2) was called on
> the output file.
> 
> This was never fixed because it was deemed ´silly developer, don˙t
> close stdout and stderr before invoking ddˇ.
> 
> The argument has been made by Jilles T. that it is generally a bad
> idea to close down any of the standard file descriptors because it
> cannot be predicted how a particular UNIX utility will react (e.g., in
> the case of dd, causing a simple printf(3) to go to an unexpected
> location).

Shades of:

- From our Harris VOS system.
   JOBCNTRL ER  2211 : IT'S NOT NICE TO FOOL POP!
   >he 2211
   YOU JUST TRIED TO FAKE-OUT MOTHER NATURE, AND SHE CAUGHT YOU!  SUPER-
   VULCAN NOW HAS YOUR NAME ON HIS ENEMY LIST, AND YOU CAN BE CERTAIN THAT
   FUTURE ATTEMPTS TO RESOURCE LFN 0,3,OR 6 WILL RESULT IN YOUR BEING
   ABORTED, SPINDLED, MANGLED, FOLDED, PUNCHED, DELETED, AND DEALLOCATED.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703090019.v290Jlpk004822>