Discussion:
[ast-developers] [patch] Fix to prevent the shell from closing |shp->pwdfd| ...
Roland Mainz
2013-07-24 23:37:28 UTC
Permalink
Hi!

----

Below is a small fix to prevent ast-ksh.2013-07-19 from closing the
pwdfd. We've hit this when running the ksh93 test suite:
-- snip --
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c
build_i386_64bit_debug_cdfixes/src/cmd/ksh93/sh/xec.c
--- src/cmd/ksh93/sh/xec.c 2013-07-18 20:35:53.000000000 +0200
+++ src/cmd/ksh93/sh/xec.c 2013-07-23 05:42:49.025713788 +0200
@@ -1351,7 +1351,7 @@
/* do close-on-exec */
int fd;
for(fd=0; fd <
shp->gd->lim.open_max; fd++)
-
if((shp->fdstatus[fd]&IOCLEX)&&fd!=shp->infd)
+
if((shp->fdstatus[fd]&IOCLEX) && (fd!=shp->infd) && (fd!=shp->pwdfd))

sh_close(fd);
}
if(argn)
-- snip --

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Irek Szczesniak
2013-07-27 12:54:15 UTC
Permalink
Post by Roland Mainz
Hi!
----
Below is a small fix to prevent ast-ksh.2013-07-19 from closing the
-- snip --
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c
build_i386_64bit_debug_cdfixes/src/cmd/ksh93/sh/xec.c
--- src/cmd/ksh93/sh/xec.c 2013-07-18 20:35:53.000000000 +0200
+++ src/cmd/ksh93/sh/xec.c 2013-07-23 05:42:49.025713788 +0200
@@ -1351,7 +1351,7 @@
/* do close-on-exec */
int fd;
for(fd=0; fd <
shp->gd->lim.open_max; fd++)
-
if((shp->fdstatus[fd]&IOCLEX)&&fd!=shp->infd)
+
if((shp->fdstatus[fd]&IOCLEX) && (fd!=shp->infd) && (fd!=shp->pwdfd))
sh_close(fd);
}
if(argn)
-- snip --
Roland, thank you for catching that *BASTARD* of a bug. We've finally
figured that this was causing some weird failures if a builtin was the
last one in a command sequence (before the shell exits) and used
shp->pwdfd. Gave us a wonderful view of EBADF for no good reason.

Irek

Loading...