When exiting on SIGINT, exit with signal status

This commit is contained in:
Martin Cracauer 1998-08-24 10:17:20 +00:00
parent 2e809930ba
commit 9a4902a99f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=38520
6 changed files with 31 additions and 11 deletions

View File

@ -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);
}
/*-

View File

@ -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);
}
/*

View File

@ -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

View File

@ -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 "

View File

@ -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);
}

View File

@ -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;
}