diff options
author | cracauer <cracauer@FreeBSD.org> | 1998-08-24 10:17:20 +0000 |
---|---|---|
committer | cracauer <cracauer@FreeBSD.org> | 1998-08-24 10:17:20 +0000 |
commit | f3d290b0b53aa55bf027aba6c54dd0e5b1d101f3 (patch) | |
tree | f26bf7d06a6acaf0ba2829e55a588da97f3ea4a7 /usr.bin | |
parent | 5112766b07ec301856c63e772236ab606ccb7942 (diff) | |
download | FreeBSD-src-f3d290b0b53aa55bf027aba6c54dd0e5b1d101f3.zip FreeBSD-src-f3d290b0b53aa55bf027aba6c54dd0e5b1d101f3.tar.gz |
When exiting on SIGINT, exit with signal status
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/compat.c | 7 | ||||
-rw-r--r-- | usr.bin/make/job.c | 5 | ||||
-rw-r--r-- | usr.bin/mkdep/mkdep.gcc.sh | 4 | ||||
-rw-r--r-- | usr.bin/mkdep/mkdep.sh | 2 | ||||
-rw-r--r-- | usr.bin/time/time.c | 14 | ||||
-rw-r--r-- | usr.bin/truss/main.c | 10 |
6 files changed, 31 insertions, 11 deletions
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index ce156cf..bff02c8 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: compat.c,v 1.9 1998/05/12 11:54:12 wosch Exp $ + * $Id: compat.c,v 1.10 1998/05/13 05:50:42 jb Exp $ */ #ifndef lint @@ -129,7 +129,10 @@ CompatInterrupt (signo) } } - exit (signo); + if (signo == SIGQUIT) + exit(signo); + (void) signal(signo, SIG_DFL); + (void) kill(getpid(), signo); } /*- diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 0b06d74..d7451fc 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: job.c,v 1.8 1998/04/28 05:08:10 imp Exp $ + * $Id: job.c,v 1.9 1998/06/04 05:48:57 bde Exp $ */ #ifndef lint @@ -399,7 +399,7 @@ JobPassSig(signo) * Leave gracefully if SIGQUIT, rather than core dumping. */ if (signo == SIGQUIT) { - Finish(0); + signo = SIGINT; } /* @@ -2914,7 +2914,6 @@ JobInterrupt(runINTERRUPT, signo) } } (void) eunlink(tfile); - exit(signo); } /* diff --git a/usr.bin/mkdep/mkdep.gcc.sh b/usr.bin/mkdep/mkdep.gcc.sh index 1b0ffab..157210a 100644 --- a/usr.bin/mkdep/mkdep.gcc.sh +++ b/usr.bin/mkdep/mkdep.gcc.sh @@ -32,7 +32,7 @@ # SUCH DAMAGE. # # @(#)mkdep.gcc.sh 8.1 (Berkeley) 6/6/93 -# $Id: mkdep.gcc.sh,v 1.12 1997/02/22 19:56:10 peter Exp $ +# $Id: mkdep.gcc.sh,v 1.13 1998/08/17 11:43:25 jb Exp $ D=.depend # default dependency file is .depend append=0 @@ -66,7 +66,7 @@ case $# in 0) esac TMP=_mkdep$$ -trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 +trap 'rm -f $TMP ; trap 2 ; kill -2 $$' 1 2 3 13 15 trap 'rm -f $TMP' 0 # For C sources, mkdep must use exactly the same cpp and predefined flags diff --git a/usr.bin/mkdep/mkdep.sh b/usr.bin/mkdep/mkdep.sh index 5344108..b039fe6 100644 --- a/usr.bin/mkdep/mkdep.sh +++ b/usr.bin/mkdep/mkdep.sh @@ -69,7 +69,7 @@ fi TMP=/tmp/mkdep$$ -trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 +trap 'rm -f $TMP ; trap 2 ; kill -2 $$' 1 2 3 13 15 cc -M $* | sed " diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c index 707ba10..f74b6db 100644 --- a/usr.bin/time/time.c +++ b/usr.bin/time/time.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: time.c,v 1.9 1998/07/27 16:54:05 des Exp $"; + "$Id: time.c,v 1.10 1998/07/28 10:08:16 des Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -57,6 +57,7 @@ static const char rcsid[] = #include <stdio.h> #include <string.h> #include <unistd.h> +#include <signal.h> static int getstathz __P((void)); static void usage __P((void)); @@ -75,6 +76,7 @@ main(argc, argv) struct rusage ru; FILE *out = stderr; char *ofn = NULL; + int exitonsig = 0; /* Die with same signal as child */ aflag = lflag = 0; while ((ch = getopt(argc, argv, "alo:")) != -1) @@ -119,8 +121,10 @@ main(argc, argv) (void)signal(SIGQUIT, SIG_IGN); while (wait3(&status, 0, &ru) != pid); /* XXX use waitpid */ gettimeofday(&after, (struct timezone *)NULL); - if (status&0377) + if ( ! WIFEXITED(status)) warnx("command terminated abnormally"); + if (WIFSIGNALED(status)) + exitonsig = WTERMSIG(status); after.tv_sec -= before.tv_sec; after.tv_usec -= before.tv_usec; if (after.tv_usec < 0) @@ -173,6 +177,12 @@ main(argc, argv) fprintf(out, "%10ld %s\n", ru.ru_nivcsw, "involuntary context switches"); } + if (exitonsig) { + if (signal(exitonsig, SIG_DFL) < 0) + perror("signal"); + else + kill(getpid(), exitonsig); + } exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE); } diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index c83946a..e5bca66 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -31,7 +31,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.8 1998/01/07 06:19:50 jmg Exp $"; + "$Id: main.c,v 1.9 1998/07/06 21:01:47 bde Exp $"; #endif /* not lint */ /* @@ -127,6 +127,7 @@ main(int ac, char **av) { struct ex_types *funcs; int in_exec = 0; char *fname = NULL; + int sigexit = 0; while ((c = getopt(ac, av, "p:o:S")) != -1) { switch (c) { @@ -216,6 +217,7 @@ main(int ac, char **av) { break; case S_SIG: fprintf(outfile, "SIGNAL %lu\n", pfs.val); + sigexit = pfs.val; break; case S_EXIT: fprintf (outfile, "process exit, rval = %lu\n", pfs.val); @@ -232,5 +234,11 @@ main(int ac, char **av) { if (ioctl(Procfd, PIOCCONT, val) == -1) warn("PIOCCONT"); } while (pfs.why != S_EXIT); + if (sigexit) { + if (sigexit == SIGQUIT) + exit(sigexit); + (void) signal(sigexit, SIG_DFL); + (void) kill(getpid(), sigexit); + } return 0; } |