half close of EXEC and SYSTEM addresses did not work with pipes and sometimes socketpair

This commit is contained in:
Gerhard Rieger 2009-03-31 22:46:41 +02:00
parent 5999bbc1b8
commit 13fce17ad8
4 changed files with 35 additions and 29 deletions

View file

@ -1,5 +1,8 @@
corrections:
half close of EXEC and SYSTEM addresses did not work for pipes and
sometimes socketpair
help displayed some option types wrong
under some circumstances shutdown was called multiple times for the

View file

@ -1 +1 @@
"1.7.0.0"
"1.7.0.0+execshut"

45
test.sh
View file

@ -2272,14 +2272,13 @@ esac
N=$((N+1))
## LATER:
#NAME=SYSTEMPIPESFLUSH
#case "$TESTS" in
#*%functions%*|*%system%*|*%$NAME%*)
#TEST="$NAME: call to od via system() with pipes"
#testod "$N" "$TEST" "" "system:$OD_C,pipes" "$opts"
#esac
#N=$((N+1))
NAME=SYSTEMPIPESFLUSH
case "$TESTS" in
*%functions%*|*%system%*|*%$NAME%*)
TEST="$NAME: call to od via system() with pipes"
testod "$N" "$TEST" "" "system:$OD_C,pipes" "$opts" "$val_t"
esac
N=$((N+1))
## LATER:
@ -2312,24 +2311,22 @@ N=$((N+1))
#N=$((N+1))
## LATER:
#NAME=SYSTEMPIPESFDSFLUSH
#case "$TESTS" in
#*%functions%*|*%system%*|*%$NAME%*)
#TEST="$NAME: call to od via system() with pipes, non stdio"
#testod "$N" "$TEST" "" "system:$OD_C>&9 <&8,pipes,fdin=8,fdout=9" "$opts"
#esac
#N=$((N+1))
NAME=SYSTEMPIPESFDSFLUSH
case "$TESTS" in
*%functions%*|*%system%*|*%$NAME%*)
TEST="$NAME: call to od via system() with pipes, non stdio"
testod "$N" "$TEST" "" "system:$OD_C>&9 <&8,pipes,fdin=8,fdout=9" "$opts" "$val_t"
esac
N=$((N+1))
## LATER:
#NAME=DUALSYSTEMFDSFLUSH
#case "$TESTS" in
#*%functions%*|*%system%*|*%$NAME%*)
#TEST="$NAME: call to od via dual system()"
#testecho "$N" "$TEST" "system:$OD_C>&6,fdout=6!!system:$CAT<&7,fdin=7" "" "$opts"
#esac
#N=$((N+1))
NAME=DUALSYSTEMFDSFLUSH
case "$TESTS" in
*%functions%*|*%system%*|*%$NAME%*)
TEST="$NAME: call to od via dual system()"
testod "$N" "$TEST" "system:$OD_C>&6,fdout=6!!system:$CAT<&7,fdin=7" "pipe" "$opts" "$val_t"
esac
N=$((N+1))
case "$UNAME" in

View file

@ -1,5 +1,5 @@
/* source: xio-progcall.c */
/* Copyright Gerhard Rieger 2001-2008 */
/* Copyright Gerhard Rieger 2001-2009 */
/* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains common code dealing with program calls (exec, system) */
@ -420,6 +420,7 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
#if HAVE_PTY
if (usepty) {
Close(ptyfd);
if (rw != XIO_RDONLY && fdi != ttyfd) {
if (Dup2(ttyfd, fdi) < 0) {
Error3("dup2(%d, %d): %s", ttyfd, fdi, strerror(errno));
@ -448,6 +449,8 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
a graceful solution via temporary descriptors */
int tmpi, tmpo;
if (rw != XIO_WRONLY) Close(rdpip[0]);
if (rw != XIO_RDONLY) Close(wrpip[1]);
if (fdi == rdpip[1]) { /* a conflict here */
if ((tmpi = Dup(wrpip[0])) < 0) {
Error2("dup(%d): %s", wrpip[0], strerror(errno));
@ -491,6 +494,7 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
applyopts(fdo, *copts, PH_LATE2);
} else { /* socketpair */
Close(sv[0]);
if (rw != XIO_RDONLY && fdi != sv[1]) {
if (Dup2(sv[1], fdi) < 0) {
Error3("dup2(%d, %d): %s", sv[1], fdi, strerror(errno));
@ -505,6 +509,7 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
}
if (fdi != sv[1] && fdo != sv[1]) {
applyopts_cloexec(sv[1], *copts);
Close(sv[1]);
}
applyopts(fdi, *copts, PH_LATE);
@ -546,13 +551,14 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
if (Close(ttyfd) < 0) {
Info2("close(%d): %s", ttyfd, strerror(errno));
}
} /*0 else*/
} else
#endif /* HAVE_PTY */
#if 0
if (usepipes) {
Close(rdpip[1]);
Close(wrpip[0]);
} else {
Close(sv[1]);
}
#endif
fd->para.exec.pid = pid;
if (applyopts_single(fd, popts, PH_LATE) < 0) return -1;