svn commit: [25765] trunk/busybox/shell
vda at busybox.net
vda at busybox.net
Fri Mar 20 01:24:08 UTC 2009
Author: vda
Date: 2009-03-20 01:24:08 +0000 (Fri, 20 Mar 2009)
New Revision: 25765
Log:
ash: fix a case where we close wrong descriptor; add debug hack for that
Modified:
trunk/busybox/shell/ash.c
Changeset:
Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c 2009-03-19 23:21:55 UTC (rev 25764)
+++ trunk/busybox/shell/ash.c 2009-03-20 01:24:08 UTC (rev 25765)
@@ -260,6 +260,12 @@
static void trace_vprintf(const char *fmt, va_list va);
# define TRACE(param) trace_printf param
# define TRACEV(param) trace_vprintf param
+# define close(f) do { \
+ int dfd = (f); \
+ if (close(dfd) < 0) \
+ bb_error_msg("bug on %d: closing %d(%x)", \
+ __LINE__, dfd dfd); \
+} while (0)
#else
# define TRACE(param)
# define TRACEV(param)
@@ -5142,7 +5148,9 @@
if (newfd < 0) {
/* NTOFD/NFROMFD: copy redir->ndup.dupfd to fd */
if (redir->ndup.dupfd < 0) { /* "fd>&-" */
- close(fd);
+ /* Don't want to trigger debugging */
+ if (fd != -1)
+ close(fd);
} else {
copyfd(redir->ndup.dupfd, fd | COPYFD_EXACT);
}
@@ -5195,7 +5203,7 @@
/*close(fd);*/
copyfd(copy, fd | COPYFD_EXACT);
}
- close(copy);
+ close(copy & ~COPYFD_RESTORE);
}
}
redirlist = rp->next;
@@ -8416,7 +8424,9 @@
if (prevfd >= 0)
close(prevfd);
prevfd = pip[0];
- close(pip[1]);
+ /* Don't want to trigger debugging */
+ if (pip[1] != -1)
+ close(pip[1]);
}
if (n->npipe.pipe_backgnd == 0) {
exitstatus = waitforjob(jp);
More information about the busybox-cvs
mailing list