diff options
author | mp <mp@FreeBSD.org> | 2005-04-24 19:41:08 +0000 |
---|---|---|
committer | mp <mp@FreeBSD.org> | 2005-04-24 19:41:08 +0000 |
commit | 94a109bd814074f290affa8f7698847719d55833 (patch) | |
tree | 6daeb0464a7bc8705c0246b7fd98e212b6beed09 /contrib/tcsh/sh.sem.c | |
parent | bbd1addf8f9452690ad13ce5b875ee4cc9633958 (diff) | |
download | FreeBSD-src-94a109bd814074f290affa8f7698847719d55833.zip FreeBSD-src-94a109bd814074f290affa8f7698847719d55833.tar.gz |
Import of tcsh-6.14.00
Diffstat (limited to 'contrib/tcsh/sh.sem.c')
-rw-r--r-- | contrib/tcsh/sh.sem.c | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/contrib/tcsh/sh.sem.c b/contrib/tcsh/sh.sem.c index a7839af..97d10e0 100644 --- a/contrib/tcsh/sh.sem.c +++ b/contrib/tcsh/sh.sem.c @@ -1,4 +1,4 @@ -/* $Header: /src/pub/tcsh/sh.sem.c,v 3.60 2004/02/23 15:04:36 christos Exp $ */ +/* $Header: /src/pub/tcsh/sh.sem.c,v 3.69 2005/01/18 20:24:51 christos Exp $ */ /* * sh.sem.c: I/O redirections and job forking. A touchy issue! * Most stuff with builtins is incorrect @@ -33,7 +33,7 @@ */ #include "sh.h" -RCSID("$Id: sh.sem.c,v 3.60 2004/02/23 15:04:36 christos Exp $") +RCSID("$Id: sh.sem.c,v 3.69 2005/01/18 20:24:51 christos Exp $") #include "tc.h" #include "tw.h" @@ -50,13 +50,13 @@ RCSID("$Id: sh.sem.c,v 3.60 2004/02/23 15:04:36 christos Exp $") #endif /* CLOSE_ON_EXEC */ #if defined(__sparc__) || defined(sparc) -# if !defined(MACH) && SYSVREL == 0 && !defined(Lynx) && !defined(BSD4_4) && !defined(linux) +# if !defined(MACH) && SYSVREL == 0 && !defined(Lynx) && !defined(BSD4_4) && !defined(linux) && !defined(__GNU__) && !defined(__GLIBC__) # include <vfork.h> -# endif /* !MACH && SYSVREL == 0 && !Lynx && !BSD4_4 && !linux */ +# endif /* !MACH && SYSVREL == 0 && !Lynx && !BSD4_4 && !glibc */ #endif /* __sparc__ || sparc */ #ifdef VFORK -static sigret_t vffree __P((int)); +static RETSIGTYPE vffree __P((int)); #endif static Char *splicepipe __P((struct command *, Char *)); static void doio __P((struct command *, int *, int *)); @@ -85,16 +85,12 @@ static void chkclob __P((char *)); /*VARARGS 1*/ void execute(t, wanttty, pipein, pipeout, do_glob) - register struct command *t; + struct command *t; int wanttty; int *pipein, *pipeout; - bool do_glob; + int do_glob; { -#ifdef VFORK - extern bool use_fork; /* use fork() instead of vfork()? */ -#endif - - bool forked = 0; + int forked = 0; struct biltins *bifunc; int pid = 0; int pv[2]; @@ -522,7 +518,7 @@ execute(t, wanttty, pipein, pipeout, do_glob) else { /* child */ /* this is from pfork() */ int pgrp; - bool ignint = 0; + int ignint = 0; if (nosigchld) { # ifdef BSDSIGS (void) sigsetmask(csigmask); @@ -579,13 +575,13 @@ execute(t, wanttty, pipein, pipeout, do_glob) (void) signal(SIGHUP, SIG_DFL); if (t->t_dflg & F_NICE) { int nval = SIGN_EXTEND_CHAR(t->t_nice); -# ifdef BSDNICE +# ifdef HAVE_SETPRIORITY if (setpriority(PRIO_PROCESS, 0, nval) == -1 && errno) stderror(ERR_SYSTEM, "setpriority", strerror(errno)); -# else /* !BSDNICE */ +# else /* !HAVE_SETPRIORITY */ (void) nice(nval); -# endif /* BSDNICE */ +# endif /* HAVE_SETPRIORITY */ } # ifdef F_VER if (t->t_dflg & F_VER) { @@ -654,6 +650,13 @@ execute(t, wanttty, pipein, pipeout, do_glob) func(t, bifunc); if (forked) exitstat(); + else { + if (adrof(STRprintexitvalue)) { + int rv = getn(varval(STRstatus)); + if (rv != 0) + xprintf(CGETS(17, 2, "Exit %d\n"), rv); + } + } break; } if (t->t_dtyp != NODE_PAREN) { @@ -663,15 +666,19 @@ execute(t, wanttty, pipein, pipeout, do_glob) /* * For () commands must put new 0,1,2 in FSH* and recurse */ - OLDSTD = dcopy(0, FOLDSTD); - SHOUT = dcopy(1, FSHOUT); + (void)close_on_exec(OLDSTD = dcopy(0, FOLDSTD), 1); + (void)close_on_exec(SHOUT = dcopy(1, FSHOUT), 1); isoutatty = isatty(SHOUT); - SHDIAG = dcopy(2, FSHDIAG); + (void)close_on_exec(SHDIAG = dcopy(2, FSHDIAG), 1); isdiagatty = isatty(SHDIAG); (void) close(SHIN); SHIN = -1; #ifndef CLOSE_ON_EXEC didcch = 0; +#else + (void) close_on_exec(FSHOUT, 1); + (void) close_on_exec(FSHDIAG, 1); + (void) close_on_exec(FOLDSTD, 1); #endif /* !CLOSE_ON_EXEC */ didfds = 0; wanttty = -1; @@ -747,12 +754,12 @@ execute(t, wanttty, pipein, pipeout, do_glob) } #ifdef VFORK -static sigret_t +static RETSIGTYPE /*ARGSUSED*/ vffree(snum) int snum; { - register Char **v; + Char **v; USE(snum); if ((v = gargv) != 0) { @@ -766,10 +773,6 @@ int snum; } _exit(1); -#ifndef SIGVOID - /*NOTREACHED*/ - return(0); -#endif /* SIGVOID */ } #endif /* VFORK */ @@ -790,7 +793,7 @@ int snum; */ static Char * splicepipe(t, cp) - register struct command *t; + struct command *t; Char *cp; /* word after < or > */ { Char *blk[2]; @@ -836,12 +839,12 @@ splicepipe(t, cp) */ static void doio(t, pipein, pipeout) - register struct command *t; + struct command *t; int *pipein, *pipeout; { - register int fd; - register Char *cp; - register unsigned long flags = t->t_dflg; + int fd; + Char *cp; + unsigned long flags = t->t_dflg; if (didfds || (flags & F_REPEAT)) return; @@ -863,7 +866,7 @@ doio(t, pipein, pipeout) stderror(ERR_SYSTEM, tmp, strerror(errno)); /* allow input files larger than 2Gb */ #ifndef WINNT_NATIVE - (void) fcntl(fd, O_LARGEFILE, 0); + (void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_LARGEFILE); #endif /*!WINNT_NATIVE*/ (void) dmove(fd, 0); } @@ -923,7 +926,7 @@ doio(t, pipein, pipeout) stderror(ERR_SYSTEM, tmp, strerror(errno)); /* allow input files larger than 2Gb */ #ifndef WINNT_NATIVE - (void) fcntl(fd, O_LARGEFILE, 0); + (void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_LARGEFILE); #endif /*!WINNT_NATIVE*/ } (void) dmove(fd, 1); @@ -960,13 +963,13 @@ doio(t, pipein, pipeout) void mypipe(pv) - register int *pv; + int *pv; { if (pipe(pv) < 0) goto oops; - pv[0] = dmove(pv[0], -1); - pv[1] = dmove(pv[1], -1); + (void)close_on_exec(pv[0] = dmove(pv[0], -1), 1); + (void)close_on_exec(pv[1] = dmove(pv[1], -1), 1); if (pv[0] >= 0 && pv[1] >= 0) return; oops: @@ -975,7 +978,7 @@ oops: static void chkclob(cp) - register char *cp; + char *cp; { struct stat stb; |