[BusyBox-cvs] CVS update of busybox/shell (lash.c)
Erik Andersen
andersen at codepoet.org
Mon Aug 16 08:38:36 UTC 2004
Date: Monday, August 16, 2004 @ 02:38:35
Author: andersen
Path: /var/cvs/busybox/shell
Modified: lash.c (1.160 -> 1.161)
Joe.C writes:
This bug is in busybox 1.0.0-rc2. When using lash exec
builtin with redirection, the opened file fd keep increasing.
For example, please try the following command with lash.
ls -al /proc/<lash pid>/fd
exec /bin/sh 2>/dev/null
ls -al /proc/<lash pid>/fd
The last 'ls' command output will look like this. The fd
number 4 shouldn't exist.
lrwx------ 1 501 100 64 Aug 13 13:56 4 -> /dev/pts/5
l-wx------ 1 501 100 64 Aug 13 13:56 2 -> /dev/null
lrwx------ 1 501 100 64 Aug 13 13:56 1 -> /dev/pts/5
lrwx------ 1 501 100 64 Aug 13 13:56 0 -> /dev/pts/5
dr-xr-xr-x 3 501 100 0 Aug 13 13:56 ..
dr-x------ 2 501 100 0 Aug 13 13:56 .
This one-line patch fix this problem by setting CLOEXEC flag for
squirrel fd. Please apply.
Joe.C
Index: busybox/shell/lash.c
diff -u busybox/shell/lash.c:1.160 busybox/shell/lash.c:1.161
--- busybox/shell/lash.c:1.160 Mon Apr 12 11:59:24 2004
+++ busybox/shell/lash.c Mon Aug 16 02:38:34 2004
@@ -656,6 +656,7 @@
if (openfd != redir->fd) {
if (squirrel && redir->fd < 3) {
squirrel[redir->fd] = dup(redir->fd);
+ fcntl (squirrel[redir->fd], F_SETFD, FD_CLOEXEC);
}
dup2(openfd, redir->fd);
close(openfd);
More information about the busybox-cvs
mailing list