Date: Mon, 22 Jun 1998 11:30:02 -0700 (PDT) From: Stefan Eggers <seggers@semyam.dinoco.de> To: freebsd-bugs@FreeBSD.ORG Subject: Re: bin/7020: pkg_*'s error handling is broken Message-ID: <199806221830.LAA28273@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/7020; it has been noted by GNATS.
From: Stefan Eggers <seggers@semyam.dinoco.de>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc: seggers@semyam.dinoco.de
Subject: Re: bin/7020: pkg_*'s error handling is broken
Date: Mon, 22 Jun 1998 20:24:40 +0200
Hi!
Now I have a diff ready to fix the problem. If a context diff is
preferable I'll make those the next time I send something in.
Stefan.
diff -ru pkg_install/add/perform.c pkg_install.NEW/add/perform.c
--- pkg_install/add/perform.c Mon Feb 16 18:41:31 1998
+++ pkg_install.NEW/add/perform.c Mon Jun 22 20:06:06 1998
@@ -39,8 +39,8 @@
{
int i, err_cnt = 0;
- signal(SIGINT, cleanup);
- signal(SIGHUP, cleanup);
+ signal(SIGINT, signalcleanup);
+ signal(SIGHUP, signalcleanup);
if (AddMode == SLAVE)
err_cnt = pkg_do(NULL);
@@ -480,5 +480,11 @@
vsystem("%s -rf %s", REMOVE_CMD, LogDir);
leave_playpen();
}
+}
+
+void
+signalcleanup(int signo)
+{
+ cleanup(signo);
exit(1);
}
diff -ru pkg_install/create/perform.c pkg_install.NEW/create/perform.c
--- pkg_install/create/perform.c Mon Feb 16 18:41:38 1998
+++ pkg_install.NEW/create/perform.c Mon Jun 22 20:11:09 1998
@@ -118,8 +118,8 @@
/* Make a directory to stomp around in */
home = make_playpen(PlayPen, 0);
- signal(SIGINT, cleanup);
- signal(SIGHUP, cleanup);
+ signal(SIGINT, signalcleanup);
+ signal(SIGHUP, signalcleanup);
/* Make first "real contents" pass over it */
check_list(home, &plist);
@@ -288,13 +288,21 @@
/* Clean up those things that would otherwise hang around */
void
-cleanup(int sig)
+cleanup(int signo)
{
- int in_cleanup = 0;
+ static int in_cleanup = 0;
if (!in_cleanup) {
in_cleanup = 1;
+ if (signo)
+ printf("Signal %d received, cleaning up..\n", signo);
leave_playpen();
}
+}
+
+void
+signalcleanup(int signo)
+{
+ cleanup(signo);
exit(1);
}
diff -ru pkg_install/delete/perform.c pkg_install.NEW/delete/perform.c
--- pkg_install/delete/perform.c Mon Oct 13 17:06:12 1997
+++ pkg_install.NEW/delete/perform.c Mon Jun 22 20:10:09 1998
@@ -162,7 +162,6 @@
cleanup(int sig)
{
/* Nothing to do */
- exit(1);
}
static void
diff -ru pkg_install/info/perform.c pkg_install.NEW/info/perform.c
--- pkg_install/info/perform.c Mon Feb 16 18:41:44 1998
+++ pkg_install.NEW/info/perform.c Mon Jun 22 20:16:35 1998
@@ -36,7 +36,8 @@
int i, err_cnt = 0;
char *tmp;
- signal(SIGINT, cleanup);
+ signal(SIGINT, signalcleanup);
+ signal(SIGHUP, signalcleanup);
tmp = getenv(PKG_DBDIR);
if (!tmp)
@@ -207,5 +208,11 @@
in_cleanup = 1;
leave_playpen();
}
+}
+
+void
+signalcleanup(int sig)
+{
+ cleanup(sig);
exit(1);
}
diff -ru pkg_install/lib/lib.h pkg_install.NEW/lib/lib.h
--- pkg_install/lib/lib.h Mon Feb 16 18:41:51 1998
+++ pkg_install.NEW/lib/lib.h Mon Jun 22 16:19:30 1998
@@ -106,6 +106,7 @@
/* Misc */
int vsystem(const char *, ...);
void cleanup(int);
+void signalcleanup(int);
char *make_playpen(char *, size_t);
char *where_playpen(void);
void leave_playpen(void);
diff -ru pkg_install/lib/msg.c pkg_install.NEW/lib/msg.c
--- pkg_install/lib/msg.c Mon Mar 9 13:31:15 1998
+++ pkg_install.NEW/lib/msg.c Mon Jun 22 16:27:42 1998
@@ -33,6 +33,7 @@
{
warn("fatal error during execution: %s", err);
cleanup(0);
+ exit(1);
}
/*
@@ -55,6 +56,7 @@
if (!tty) {
warnx("can't open /dev/tty!");
cleanup(0);
+ exit(1);
}
while (ch != 'Y' && ch != 'N') {
vfprintf(stderr, msg, args);
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806221830.LAA28273>
