This is a bash bug. (It exists at version 2.03, propably earlier.)
I will cook up a bashbug report.
Lets look for possible places:
[bash-2.03]$ egrep dup2 *.c
execute_cmd.c: dup2 (fd, 0);
execute_cmd.c: if (dup2 (pipe_in, 0) < 0)
execute_cmd.c: if (dup2 (pipe_out, 1) < 0)
execute_cmd.c: if (dup2 (1, 2) < 0)
general.c: if (nfds && fd != nfds && (script_fd = dup2 (fd, nfds)) != -1)
input.c:/* This is the buffered stream analogue of dup2(fd1, fd2). The
redir.c: if ((fd != redirector) && (dup2 (fd, redirector) < 0))
redir.c: if (dup2 (1, 2) < 0)
redir.c: if (fd != redirector && dup2 (fd, redirector) < 0)
redir.c: /* This is correct. 2>&1 means dup2 (1, 2); */
redir.c: if (dup2 (redir_fd, redirector) < 0)
redir.c: /* First duplicate the close-on-exec state of redirectee. dup2
shell.c: dup2 (fd, 0);
subst.c: if (dup2 (fd, open_for_read_in_child ? 0 : 1) < 0)
subst.c: if (dup2 (fildes[1], 1) < 0)
Which of those ?
There are possibilities within redir.c, and general.c,
but I would bet virtual drink on that general.c being
the problem spot..
The code in there does not set close-on-exec flag for that fd.
( dup2() does clear close-on-exec flag for the new instance
of the fd.. )
> Thanks,
> Sushil.
/Matti Aarnio <matti.aarnio@sonera.fi>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/