summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/add
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-26 05:04:34 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-26 05:04:34 +0000
commit42c156187e1501831aed701070935c6e1cc4fcb3 (patch)
tree604514bb78ab651f88a031808e09ad4ab444c6b4 /usr.sbin/pkg_install/add
parenta97cf58f2b9ffb68f4c476a5bd2e42a6e0d1648c (diff)
mostly mark signal races
Diffstat (limited to 'usr.sbin/pkg_install/add')
-rw-r--r--usr.sbin/pkg_install/add/perform.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 1e2d4a4ded8..99937e8b3f9 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: perform.c,v 1.21 2001/11/17 10:40:05 espie Exp $ */
+/* $OpenBSD: perform.c,v 1.22 2001/11/26 05:04:33 deraadt Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: perform.c,v 1.21 2001/11/17 10:40:05 espie Exp $";
+static const char *rcsid = "$OpenBSD: perform.c,v 1.22 2001/11/26 05:04:33 deraadt Exp $";
#endif
/*
@@ -28,9 +28,10 @@ static const char *rcsid = "$OpenBSD: perform.c,v 1.21 2001/11/17 10:40:05 espie
#include "lib.h"
#include "add.h"
+#include <sys/wait.h>
#include <ctype.h>
#include <signal.h>
-#include <sys/wait.h>
+#include <errno.h>
static int pkg_do(char *);
static int sanity_check(char *);
@@ -583,22 +584,29 @@ sanity_check(char *pkg)
void
cleanup(int signo)
{
+ int save_errno = errno;
static int alreadyCleaning;
void (*oldint)(int);
void (*oldhup)(int);
+ char buf[1024];
oldint = signal(SIGINT, SIG_IGN);
oldhup = signal(SIGHUP, SIG_IGN);
+ /* XXX big signal race, nearly all of it! */
if (!alreadyCleaning) {
alreadyCleaning = 1;
- if (signo)
- printf("Signal %d received, cleaning up\n", signo);
+ if (signo) {
+ snprintf(buf, sizeof buf,
+ "Signal %d received, cleaning up\n", signo);
+ write(STDOUT_FILENO, buf, strlen(buf));
+ }
if (!Fake && zapLogDir && LogDir[0])
- vsystem("%s -rf %s", REMOVE_CMD, LogDir);
- leave_playpen(Home);
+ vsystem("%s -rf %s", REMOVE_CMD, LogDir); /* XXX */
+ leave_playpen(Home); /* XXX */
if (signo)
- exit(1);
+ _exit(1);
}
signal(SIGINT, oldint);
signal(SIGHUP, oldhup);
+ errno = save_errno;
}