On Sun, Sep 09, 2007 at 07:10:59PM +0100, Stephane Chazelas wrote:
[...]
> What OS and version of glibc? I do get the error message but I
> get both a and b in the file.
> 
> That was on Linux, glibc 2.6.1.
[...]

Actually,

bash -c 'echo a; echo b > a' >&-

is enough for me to reproduce the problem.

And that program below shows the same behavior when run as 
./a.out >&-

#include <stdio.h>
#include <fcntl.h>
int main()
{
  printf("a\n");
  fflush(stdout);
  dup2(open("a", O_WRONLY|O_CREAT, 0644), 1);
  printf("b\n");
  fflush(stdout);
  return 0;
}

-- 
Stéphane


Reply via email to