diff --git a/c_sh.c b/c_sh.c index c198e80..a7f3078 100644 --- a/c_sh.c +++ b/c_sh.c @@ -1,5 +1,5 @@ -/** $MirBSD: src/bin/ksh/c_sh.c,v 2.9 2004/12/31 17:29:28 tg Exp $ */ -/* $OpenBSD: c_sh.c,v 1.26 2004/12/22 18:57:28 otto Exp $ */ +/** $MirBSD: src/bin/ksh/c_sh.c,v 2.10 2004/12/31 17:42:44 tg Exp $ */ +/* $OpenBSD: c_sh.c,v 1.21 2004/12/18 22:35:41 millert Exp $ */ /* * built-in Bourne commands @@ -10,7 +10,7 @@ #include "ksh_time.h" #include "ksh_times.h" -__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 2.9 2004/12/31 17:29:28 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 2.10 2004/12/31 17:42:44 tg Exp $"); static char *clocktos(clock_t t); @@ -808,7 +808,7 @@ c_exec(char **wp GCC_FUNC_ATTR(unused)) * keeps them open). */ if (!Flag(FSH) && i > 2 && e->savefd[i]) - fd_clexec(i); + fcntl(i, F_SETFD, FD_CLOEXEC); } e->savefd = NULL; } diff --git a/exec.c b/exec.c index 32e8794..bde3c28 100644 --- a/exec.c +++ b/exec.c @@ -1,5 +1,5 @@ -/** $MirBSD: src/bin/ksh/exec.c,v 2.8 2004/12/28 22:40:40 tg Exp $ */ -/* $OpenBSD: exec.c,v 1.39 2004/12/22 18:57:28 otto Exp $ */ +/** $MirBSD: src/bin/ksh/exec.c,v 2.9 2004/12/31 17:42:44 tg Exp $ */ +/* $OpenBSD: exec.c,v 1.35 2004/12/18 22:35:41 millert Exp $ */ /* * execute command tree @@ -10,7 +10,7 @@ #include #include "ksh_stat.h" -__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.8 2004/12/28 22:40:40 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.9 2004/12/31 17:42:44 tg Exp $"); static int comexec(struct op *t, struct tbl *volatile tp, char **ap, int volatile flags); @@ -38,24 +38,6 @@ static void dbteste_error(Test_env *te, int offset, const char *msg); static char clexec_tab[MAXFD+1]; #endif -/* - * we now use this function always. - */ -int -fd_clexec(int fd) -{ -#ifndef F_SETFD - if (fd >= 0 && fd < sizeof(clexec_tab)) { - clexec_tab[fd] = 1; - return 0; - } - return -1; -#else - return fcntl(fd, F_SETFD, 1); -#endif -} - - /* * execute command tree */ diff --git a/io.c b/io.c index 75f205e..e6c11b4 100644 --- a/io.c +++ b/io.c @@ -1,5 +1,5 @@ -/** $MirBSD: src/bin/ksh/io.c,v 2.5 2004/12/28 22:32:08 tg Exp $ */ -/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */ +/** $MirBSD: src/bin/ksh/io.c,v 2.6 2004/12/31 17:42:45 tg Exp $ */ +/* $OpenBSD: io.c,v 1.17 2004/12/18 22:35:41 millert Exp $ */ /* * shell buffered IO and formatted output @@ -259,7 +259,7 @@ savefd(int fd, int noclose) close(fd); } else nfd = fd; - fd_clexec(nfd); + fcntl(nfd, F_SETFD, FD_CLOEXEC); return nfd; } diff --git a/proto.h b/proto.h index 2cac291..68b5618 100644 --- a/proto.h +++ b/proto.h @@ -1,9 +1,9 @@ -/** $MirBSD: src/bin/ksh/proto.h,v 2.9 2004/12/31 17:29:28 tg Exp $ */ +/** $MirBSD: src/bin/ksh/proto.h,v 2.10 2004/12/31 17:42:45 tg Exp $ */ /* $OpenBSD: proto.h,v 1.11 2003/05/16 19:58:57 jsyn Exp $ */ /* $From: proto.h,v 1.3 1994/05/19 18:32:40 michael Exp michael $ */ #ifndef PROTO_H -/* $OpenBSD: proto.h,v 1.17 2004/12/18 21:58:39 millert Exp $ */ +/* $OpenBSD: proto.h,v 1.18 2004/12/18 22:35:41 millert Exp $ */ /* * prototypes for PD-KSH @@ -70,7 +70,6 @@ char *debunk(char *dp, const char *sp, size_t dlen); void expand(char *cp, XPtrV *wp, int f); int glob_str(char *cp, XPtrV *wp, int markdirs); /* exec.c */ -int fd_clexec(int fd); int execute(struct op * volatile t, volatile int flags); int shcomexec(char **wp); struct tbl * findfunc(const char *name, unsigned int h, int create); diff --git a/shf.c b/shf.c index 41cd8d3..f90f12c 100644 --- a/shf.c +++ b/shf.c @@ -1,5 +1,5 @@ -/** $MirBSD: src/bin/ksh/shf.c,v 2.3 2004/12/18 19:22:30 tg Exp $ */ -/* $OpenBSD: shf.c,v 1.8 2003/02/28 09:45:09 jmc Exp $ */ +/** $MirBSD: src/bin/ksh/shf.c,v 2.4 2004/12/31 17:42:45 tg Exp $ */ +/* $OpenBSD: shf.c,v 1.10 2004/12/18 22:35:41 millert Exp $ */ /* * Shell file I/O routines @@ -9,7 +9,7 @@ #include "ksh_stat.h" #include "ksh_limval.h" -__RCSID("$MirBSD: src/bin/ksh/shf.c,v 2.3 2004/12/18 19:22:30 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/shf.c,v 2.4 2004/12/31 17:42:45 tg Exp $"); /* flags to shf_emptybuf() */ #define EB_READSW 0x01 /* about to switch to reading */ @@ -113,7 +113,7 @@ shf_fdopen(int fd, int sflags, struct shf *shf) shf->errno_ = 0; shf->bsize = bsize; if (sflags & SHF_CLEXEC) - fd_clexec(fd); + fcntl(fd, F_SETFD, FD_CLOEXEC); return shf; } @@ -153,7 +153,7 @@ shf_reopen(int fd, int sflags, struct shf *shf) shf->flags = (shf->flags & (SHF_ALLOCS | SHF_ALLOCB)) | sflags; shf->errno_ = 0; if (sflags & SHF_CLEXEC) - fd_clexec(fd); + fcntl(fd, F_SETFD, FD_CLOEXEC); return shf; } diff --git a/tty.c b/tty.c index 2f69d30..5f2f843 100644 --- a/tty.c +++ b/tty.c @@ -1,5 +1,5 @@ -/** $MirBSD: src/bin/ksh/tty.c,v 2.3 2004/12/31 17:39:12 tg Exp $ */ -/* $OpenBSD: tty.c,v 1.4 2004/12/18 22:12:23 millert Exp $ */ +/** $MirBSD: src/bin/ksh/tty.c,v 2.4 2004/12/31 17:42:45 tg Exp $ */ +/* $OpenBSD: tty.c,v 1.5 2004/12/18 22:35:41 millert Exp $ */ #include "sh.h" #include "ksh_stat.h" @@ -7,7 +7,7 @@ #include "tty.h" #undef EXTERN -__RCSID("$MirBSD: src/bin/ksh/tty.c,v 2.3 2004/12/31 17:39:12 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/tty.c,v 2.4 2004/12/31 17:42:45 tg Exp $"); /* Initialize tty_fd. Used for saving/reseting tty modes upon * foreground job completion and for setting up tty process group. @@ -42,7 +42,7 @@ tty_init(int init_ttystate) if ((tty_fd = ksh_dupbase(tfd, FDBASE)) < 0) { warningf(false, "j_ttyinit: dup of tty fd failed: %s", strerror(errno)); - } else if (fd_clexec(tty_fd) < 0) { + } else if (fcntl(tty_fd, F_SETFD, FD_CLOEXEC) < 0) { warningf(false, "j_ttyinit: can't set close-on-exec flag: %s", strerror(errno)); close(tty_fd);