diff options
author | cracauer <cracauer@FreeBSD.org> | 1998-08-25 09:33:34 +0000 |
---|---|---|
committer | cracauer <cracauer@FreeBSD.org> | 1998-08-25 09:33:34 +0000 |
commit | 2ca0a9a7fbfb8fa635bb19255ab351359ef0d32c (patch) | |
tree | f4a8eda0d679103835834312a2c79f44c013b7f9 /bin/sh | |
parent | 3fc10b771999799e730d32054e38d93549b76b73 (diff) | |
download | FreeBSD-src-2ca0a9a7fbfb8fa635bb19255ab351359ef0d32c.zip FreeBSD-src-2ca0a9a7fbfb8fa635bb19255ab351359ef0d32c.tar.gz |
Improve bookkeeping of in_waitcmd and style fixes.
Submitted by: Bruce Evans
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/arith.y | 10 | ||||
-rw-r--r-- | bin/sh/arith_lex.l | 6 | ||||
-rw-r--r-- | bin/sh/error.c | 15 | ||||
-rw-r--r-- | bin/sh/jobs.c | 21 | ||||
-rw-r--r-- | bin/sh/jobs.h | 8 | ||||
-rw-r--r-- | bin/sh/miscbltin.c | 4 | ||||
-rw-r--r-- | bin/sh/trap.c | 4 |
7 files changed, 41 insertions, 27 deletions
diff --git a/bin/sh/arith.y b/bin/sh/arith.y index 87f2f45..655ed23 100644 --- a/bin/sh/arith.y +++ b/bin/sh/arith.y @@ -88,12 +88,16 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; } * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: arith.y,v 1.7 1998/05/18 06:43:27 charnier Exp $ + * $Id: arith.y,v 1.8 1998/08/24 10:20:36 cracauer Exp $ */ +#ifndef lint #if 0 static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "shell.h" #include "error.h" @@ -103,8 +107,8 @@ static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; char *arith_buf, *arith_startbuf; extern void arith_lex_reset(); -int yyparse(void); -int yylex(void); +int yylex __P((void)); +int yyparse __P((void)); int arith(s) diff --git a/bin/sh/arith_lex.l b/bin/sh/arith_lex.l index 6c1b171..b5ca746 100644 --- a/bin/sh/arith_lex.l +++ b/bin/sh/arith_lex.l @@ -34,12 +34,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: arith_lex.l,v 1.10 1998/05/18 06:43:28 charnier Exp $ + * $Id: arith_lex.l,v 1.11 1998/08/24 10:20:36 cracauer Exp $ */ +#ifndef lint #if 0 static char sccsid[] = "@(#)arith_lex.l 8.3 (Berkeley) 5/4/95"; #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include <unistd.h> #include "y.tab.h" diff --git a/bin/sh/error.c b/bin/sh/error.c index e690199..db0cf5d 100644 --- a/bin/sh/error.c +++ b/bin/sh/error.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95"; #endif static const char rcsid[] = - "$Id: error.c,v 1.11 1998/08/24 10:20:36 cracauer Exp $"; + "$Id: error.c,v 1.12 1998/08/24 19:15:48 cracauer Exp $"; #endif /* not lint */ /* @@ -91,7 +91,7 @@ exraise(e) /* * Called from trap.c when a SIGINT is received. (If the user specifies * that SIGINT is to be trapped or ignored using the trap builtin, then - * this routine is not called.) Supressint is nonzero when interrupts + * this routine is not called.) Suppressint is nonzero when interrupts * are held using the INTOFF macro. If SIGINTs are not suppressed and * the shell is not a root shell, then we want to be terminated if we * get here, as if we were terminated directly by a SIGINT. Arrange for @@ -102,8 +102,9 @@ void onint() { sigset_t sigset; - /* The !in_dotrap is save. The only way we can arrive here with - * in_dotrap set is that a trap handler set SIGINT to default + /* + * The !in_dotrap here is safe. The only way we can arrive here + * with in_dotrap set is that a trap handler set SIGINT to SIG_DFL * and killed itself. */ @@ -115,9 +116,9 @@ onint() { sigemptyset(&sigset); sigprocmask(SIG_SETMASK, &sigset, NULL); - /* This doesn't seem to be needed. Note that main emit a newline - * as well. - */ + /* + * This doesn't seem to be needed, since main() emits a newline. + */ #if 0 if (tcgetpgrp(0) == getpid()) write(STDERR_FILENO, "\n", 1); diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 4b5694a..202fa67 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #endif static const char rcsid[] = - "$Id: jobs.c,v 1.20 1998/05/18 06:43:47 charnier Exp $"; + "$Id: jobs.c,v 1.21 1998/08/24 10:20:36 cracauer Exp $"; #endif /* not lint */ #include <fcntl.h> @@ -87,8 +87,8 @@ MKINIT pid_t backgndpid = -1; /* pid of last background process */ int initialpgrp; /* pgrp of shell on invocation */ int curjob; /* current job */ #endif -int in_waitcmd = 0; /* Are we in waitcmd? */ -volatile sig_atomic_t breakwaitcmd = 0; /* Should wait be terminated? */ +int in_waitcmd = 0; /* are we in waitcmd()? */ +volatile sig_atomic_t breakwaitcmd = 0; /* should wait be terminated? */ #if JOBS STATIC void restartjob __P((struct job *)); @@ -97,7 +97,7 @@ STATIC void freejob __P((struct job *)); STATIC struct job *getjob __P((char *)); STATIC int dowait __P((int, struct job *)); #if SYSV -STATIC volatile int onsigchild __P((void)); +STATIC int onsigchild __P((void)); #endif STATIC int waitproc __P((int, int *)); STATIC void cmdtxt __P((union node *)); @@ -387,10 +387,14 @@ waitcmd(argc, argv) } else { job = NULL; } + + /* + * Loop until a process is terminated or stopped, or a SIGINT is + * received. + */ + in_waitcmd++; - do { /* loop until process terminated or stopped or SIGINT is - * received - */ + do { if (job != NULL) { if (job->state) { status = job->ps[job->nprocs - 1].status; @@ -404,11 +408,13 @@ waitcmd(argc, argv) retval = WTERMSIG(status) + 128; if (! iflag) freejob(job); + in_waitcmd--; return retval; } } else { for (jp = jobtab ; ; jp++) { if (jp >= jobtab + njobs) { /* no running procs */ + in_waitcmd--; return 0; } if (jp->used && jp->state == 0) @@ -418,7 +424,6 @@ waitcmd(argc, argv) } while (dowait(1, (struct job *)NULL) != -1); in_waitcmd--; - /* Not reachable */ return 0; } diff --git a/bin/sh/jobs.h b/bin/sh/jobs.h index 3182a65..b164b2f2 100644 --- a/bin/sh/jobs.h +++ b/bin/sh/jobs.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)jobs.h 8.2 (Berkeley) 5/4/95 - * $Id: jobs.h,v 1.6 1997/08/18 02:53:20 steve Exp $ + * $Id: jobs.h,v 1.7 1998/08/24 10:20:36 cracauer Exp $ */ /* Mode argument to forkshell. Don't change FORK_FG or FORK_BG. */ @@ -42,7 +42,7 @@ #define FORK_BG 1 #define FORK_NOJOB 2 -#include <signal.h> /* For sig_atomic_t */ +#include <signal.h> /* for sig_atomic_t */ /* * A job structure contains information about a job. A job is either a @@ -78,8 +78,8 @@ struct job { extern pid_t backgndpid; /* pid of last background process */ extern int job_warning; /* user was warned about stopped jobs */ -extern int in_waitcmd; /* Are we in wait? */ -extern volatile sig_atomic_t breakwaitcmd; /* Should wait be terminated? */ +extern int in_waitcmd; /* are we in waitcmd()? */ +extern volatile sig_atomic_t breakwaitcmd; /* should wait be terminated? */ void setjobctl __P((int)); int fgcmd __P((int, char **)); diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c index cde9e5d..772a3fd 100644 --- a/bin/sh/miscbltin.c +++ b/bin/sh/miscbltin.c @@ -39,14 +39,13 @@ static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95"; #endif static const char rcsid[] = - "$Id: miscbltin.c,v 1.15 1998/05/18 06:43:58 charnier Exp $"; + "$Id: miscbltin.c,v 1.16 1998/08/24 10:20:36 cracauer Exp $"; #endif /* not lint */ /* * Miscelaneous builtins. */ -#include <stdlib.h> /* strtol() */ #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> @@ -55,6 +54,7 @@ static const char rcsid[] = #include <ctype.h> #include <errno.h> #include <stdio.h> +#include <stdlib.h> #include <termios.h> #include "shell.h" diff --git a/bin/sh/trap.c b/bin/sh/trap.c index 58151f4..0d8558b 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; #endif static const char rcsid[] = - "$Id: trap.c,v 1.12 1998/08/24 10:20:36 cracauer Exp $"; + "$Id: trap.c,v 1.13 1998/08/25 08:49:47 cracauer Exp $"; #endif /* not lint */ #include <signal.h> @@ -76,7 +76,7 @@ static const char rcsid[] = MKINIT char sigmode[NSIG]; /* current value of signal */ int pendingsigs; /* indicates some signal received */ -int in_dotrap = 0; /* Do we execute in a trap handler? */ +int in_dotrap; /* do we execute in a trap handler? */ static char *trap[NSIG]; /* trap handler commands */ static volatile sig_atomic_t gotsig[NSIG]; /* indicates specified signal received */ |