diff --git a/Build.sh b/Build.sh index b271de3..b8ec4a5 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.311 2008/04/01 17:25:36 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.312 2008/04/01 20:40:20 tg Exp $' #- # Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS # CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NOPWNAM MKSH_NOVI @@ -342,8 +342,6 @@ syllable) ULTRIX) : ${CC=cc -YPOSIX} CPPFLAGS="$CPPFLAGS -Dssize_t=int" - warn=' but might work. I think that I/O' - warn="$warn${nl}redirs are kaput: child affects parent" ;; UWIN*) ccpc='-Yc,' diff --git a/check.t b/check.t index b3e4b91..814113a 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.169 2008/04/01 17:25:37 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.170 2008/04/01 20:40:21 tg Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ @@ -7,7 +7,7 @@ # http://www.research.att.com/~gsf/public/ifs.sh expected-stdout: - @(#)MIRBSD KSH R33 2008/03/28 + @(#)MIRBSD KSH R33 2008/04/01 description: Check version of shell. category: pdksh diff --git a/exec.c b/exec.c index 90a95a1..aaab3ee 100644 --- a/exec.c +++ b/exec.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.39 2007/10/25 13:27:00 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.40 2008/04/01 20:40:21 tg Exp $"); static int comexec(struct op *, struct tbl *volatile, const char **, int volatile); @@ -109,14 +109,14 @@ execute(struct op *volatile t, e->savefd[1] = savefd(1); while (t->type == TPIPE) { openpipe(pv); - (void) ksh_dup2(pv[1], 1, false); /* stdout of curr */ + ksh_dup2(pv[1], 1, false); /* stdout of curr */ /* Let exchild() close pv[0] in child * (if this isn't done, commands like * (: ; cat /etc/termcap) | sleep 1 * will hang forever). */ exchild(t->left, flags|XPIPEO|XCCLOSE, pv[0]); - (void) ksh_dup2(pv[0], 0, false); /* stdin of next */ + ksh_dup2(pv[0], 0, false); /* stdin of next */ closepipe(pv); flags |= XPIPEI; t = t->right; diff --git a/main.c b/main.c index 0bbbf41..aa85806 100644 --- a/main.c +++ b/main.c @@ -13,7 +13,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.94 2008/03/28 18:47:52 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.95 2008/04/01 20:40:21 tg Exp $"); extern char **environ; @@ -922,14 +922,19 @@ initio(void) /* A dup2() with error checking */ int -ksh_dup2(int ofd, int nfd, int errok) +ksh_dup2(int ofd, int nfd, bool errok) { - int ret = dup2(ofd, nfd); + int rv; - if (ret < 0 && errno != EBADF && !errok) + if (((rv = dup2(ofd, nfd)) < 0) && !errok && (errno != EBADF)) errorf("too many files open in shell"); - return ret; +#ifdef __ultrix + if (rv >= 0) + fcntl(nfd, F_SETFD, 0); +#endif + + return (rv); } /* diff --git a/misc.c b/misc.c index fb7c2d9..5762747 100644 --- a/misc.c +++ b/misc.c @@ -6,7 +6,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.69 2008/03/23 22:09:58 tg Exp $\t" +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.70 2008/04/01 20:40:22 tg Exp $\t" MKSH_SH_H_ID); #undef USE_CHVT @@ -1380,9 +1380,9 @@ chvt(const char *fn) errorf("chvt: setsid failed"); if ((fn != dv + 1) && ioctl(fd, TIOCSCTTY, NULL) == -1) errorf("chvt: TIOCSCTTY failed"); - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); + ksh_dup2(fd, 0, false); + ksh_dup2(fd, 1, false); + ksh_dup2(fd, 2, false); if (fd > 2) close(fd); } diff --git a/sh.h b/sh.h index c0da6d2..cf8df46 100644 --- a/sh.h +++ b/sh.h @@ -8,8 +8,8 @@ /* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */ -#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.199 2008/03/28 13:46:53 tg Exp $" -#define MKSH_VERSION "R33 2008/03/28" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.200 2008/04/01 20:40:22 tg Exp $" +#define MKSH_VERSION "R33 2008/04/01" #if HAVE_SYS_PARAM_H #include @@ -1384,7 +1384,7 @@ void shprintf(const char *, ...) __attribute__((format (printf, 1, 2))); int can_seek(int); void initio(void); -int ksh_dup2(int, int, int); +int ksh_dup2(int, int, bool); short savefd(int); void restfd(int, int); void openpipe(int *);