bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: builtin echo command redirection misbehaves in detached scripts when


From: Stephane Chazelas
Subject: Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed
Date: Sun, 9 Sep 2007 19:34:52 +0100
User-agent: Mutt/1.5.16 (2007-06-11)

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

[Prev in Thread] Current Thread [Next in Thread]