Don't exit cleanup() functions if not called from signal handler - this
will show error messages before aborting. Patch supplied by Jim Bernard <jbernard@ox.mines.edu> in PR 6010, cleanup() in delete/perform.c prepared to be used as signal handler by me.
This commit is contained in:
parent
6caa7ce3d9
commit
1285035fe7
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: perform.c,v 1.14 1998/07/12 14:05:51 hubertf Exp $ */
|
||||
/* $NetBSD: perform.c,v 1.15 1998/08/25 00:12:16 hubertf Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: perform.c,v 1.14 1998/07/12 14:05:51 hubertf Exp $");
|
||||
__RCSID("$NetBSD: perform.c,v 1.15 1998/08/25 00:12:16 hubertf Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -495,14 +495,21 @@ void
|
|||
cleanup(int signo)
|
||||
{
|
||||
static int alreadyCleaning;
|
||||
void (*oldint)(int);
|
||||
void (*oldhup)(int);
|
||||
oldint = signal(SIGINT, SIG_IGN);
|
||||
oldhup = signal(SIGHUP, SIG_IGN);
|
||||
|
||||
if (!alreadyCleaning) {
|
||||
alreadyCleaning = 1;
|
||||
if (signo)
|
||||
printf("Signal %d received, cleaning up..\n", signo);
|
||||
printf("Signal %d received, cleaning up..\n", signo);
|
||||
if (!Fake && LogDir[0])
|
||||
vsystem("%s -rf %s", REMOVE_CMD, LogDir);
|
||||
vsystem("%s -rf %s", REMOVE_CMD, LogDir);
|
||||
leave_playpen(Home);
|
||||
if (signo)
|
||||
exit(1);
|
||||
}
|
||||
exit(1);
|
||||
signal(SIGINT, oldint);
|
||||
signal(SIGHUP, oldhup);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: perform.c,v 1.7 1998/06/05 11:22:20 frueauf Exp $ */
|
||||
/* $NetBSD: perform.c,v 1.8 1998/08/25 00:12:16 hubertf Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: perform.c,v 1.7 1998/06/05 11:22:20 frueauf Exp $");
|
||||
__RCSID("$NetBSD: perform.c,v 1.8 1998/08/25 00:12:16 hubertf Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -314,6 +314,20 @@ sanity_check()
|
|||
void
|
||||
cleanup(int sig)
|
||||
{
|
||||
leave_playpen(home);
|
||||
exit(1);
|
||||
static int alreadyCleaning;
|
||||
void (*oldint)(int);
|
||||
void (*oldhup)(int);
|
||||
oldint = signal(SIGINT, SIG_IGN);
|
||||
oldhup = signal(SIGHUP, SIG_IGN);
|
||||
|
||||
if (!alreadyCleaning) {
|
||||
alreadyCleaning = 1;
|
||||
if (sig)
|
||||
printf("Signal %d received, cleaning up..\n", sig);
|
||||
leave_playpen(home);
|
||||
if (sig)
|
||||
exit(1);
|
||||
}
|
||||
signal(SIGINT, oldint);
|
||||
signal(SIGHUP, oldhup);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: perform.c,v 1.4 1997/10/17 14:54:05 lukem Exp $ */
|
||||
/* $NetBSD: perform.c,v 1.5 1998/08/25 00:12:17 hubertf Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: perform.c,v 1.4 1997/10/17 14:54:05 lukem Exp $");
|
||||
__RCSID("$NetBSD: perform.c,v 1.5 1998/08/25 00:12:17 hubertf Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -168,7 +168,8 @@ void
|
|||
cleanup(int sig)
|
||||
{
|
||||
/* Nothing to do */
|
||||
exit(1);
|
||||
if(sig) /* in case this is ever used as a signal handler */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: perform.c,v 1.6 1998/07/09 17:49:51 hubertf Exp $ */
|
||||
/* $NetBSD: perform.c,v 1.7 1998/08/25 00:12:17 hubertf Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: perform.c,v 1.6 1998/07/09 17:49:51 hubertf Exp $");
|
||||
__RCSID("$NetBSD: perform.c,v 1.7 1998/08/25 00:12:17 hubertf Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -247,6 +247,17 @@ pkg_do(char *pkg)
|
|||
void
|
||||
cleanup(int sig)
|
||||
{
|
||||
leave_playpen(Home);
|
||||
exit(1);
|
||||
static int alreadyCleaning;
|
||||
void (*oldint)(int);
|
||||
oldint = signal(SIGINT, SIG_IGN);
|
||||
|
||||
if (!alreadyCleaning) {
|
||||
alreadyCleaning = 1;
|
||||
if (sig)
|
||||
printf("Signal %d received, cleaning up..\n", sig);
|
||||
leave_playpen(Home);
|
||||
if (sig)
|
||||
exit(1);
|
||||
}
|
||||
signal(SIGINT, oldint);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: msg.c,v 1.4 1997/10/17 14:54:41 lukem Exp $ */
|
||||
/* $NetBSD: msg.c,v 1.5 1998/08/25 00:12:17 hubertf Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: msg.c,v 1.10 1997/10/13 15:03:55 jkh Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: msg.c,v 1.4 1997/10/17 14:54:41 lukem Exp $");
|
||||
__RCSID("$NetBSD: msg.c,v 1.5 1998/08/25 00:12:17 hubertf Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -35,10 +35,10 @@ __RCSID("$NetBSD: msg.c,v 1.4 1997/10/17 14:54:41 lukem Exp $");
|
|||
|
||||
/* Die a relatively simple death */
|
||||
void
|
||||
upchuck(const char *err)
|
||||
upchuck(const char *errstr)
|
||||
{
|
||||
warn("fatal error during execution: %s", err);
|
||||
cleanup(0);
|
||||
err(1, "fatal error during execution: %s", errstr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -59,8 +59,8 @@ y_or_n(Boolean def, const char *msg, ...)
|
|||
*/
|
||||
tty = fopen("/dev/tty", "r");
|
||||
if (!tty) {
|
||||
warnx("can't open /dev/tty!");
|
||||
cleanup(0);
|
||||
errx(1, "can't open /dev/tty!");
|
||||
}
|
||||
while (ch != 'Y' && ch != 'N') {
|
||||
vfprintf(stderr, msg, args);
|
||||
|
|
Loading…
Reference in New Issue