summaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>2007-10-14 04:54:34 +0000
committerlukem <lukem@NetBSD.org>2007-10-14 04:54:34 +0000
commitbd560fde318dda837a52bbe46abc3d2916a129a5 (patch)
tree6e5c08e98d1a30a5605adfb30f0f65e118806848 /usr.bin/patch
parentee740853d73dbc89ddad775377a6ad5a7350479d (diff)
Convert to using raise_default_signal(3).
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/Makefile5
-rw-r--r--usr.bin/patch/common.h3
-rw-r--r--usr.bin/patch/patch.c24
-rw-r--r--usr.bin/patch/util.c8
4 files changed, 30 insertions, 10 deletions
diff --git a/usr.bin/patch/Makefile b/usr.bin/patch/Makefile
index 36dd50cb0cc..33f1075c079 100644
--- a/usr.bin/patch/Makefile
+++ b/usr.bin/patch/Makefile
@@ -1,6 +1,9 @@
-# $NetBSD: Makefile,v 1.7 2002/03/11 18:47:51 kristerw Exp $
+# $NetBSD: Makefile,v 1.8 2007/10/14 04:54:34 lukem Exp $
PROG= patch
SRCS= patch.c pch.c inp.c version.c util.c backupfile.c
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
+
.include <bsd.prog.mk>
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index cf69f2c0920..2a53f03f537 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -1,4 +1,4 @@
-/* $NetBSD: common.h,v 1.17 2005/03/25 23:00:55 skd Exp $ */
+/* $NetBSD: common.h,v 1.18 2007/10/14 04:54:34 lukem Exp $ */
/*
* Copyright (c) 1988, Larry Wall
@@ -161,3 +161,4 @@ EXT char *revision INIT(NULL); /* prerequisite revision, if any */
#endif
void my_exit(int) __attribute__((__noreturn__));
+void my_sig_exit(int) __attribute__((__noreturn__));
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 283f3395e67..63404f85565 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: patch.c,v 1.24 2005/03/25 23:55:02 wiz Exp $ */
+/* $NetBSD: patch.c,v 1.25 2007/10/14 04:54:34 lukem Exp $ */
/* patch - a program to apply diffs to original files
*
@@ -25,7 +25,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: patch.c,v 1.24 2005/03/25 23:55:02 wiz Exp $");
+__RCSID("$NetBSD: patch.c,v 1.25 2007/10/14 04:54:34 lukem Exp $");
#endif /* not lint */
#include "INTERN.h"
@@ -39,6 +39,7 @@ __RCSID("$NetBSD: patch.c,v 1.24 2005/03/25 23:55:02 wiz Exp $");
#include <stdlib.h>
#include <unistd.h>
+#include <util.h>
/* procedures */
static void reinitialize_almost_everything(void);
@@ -911,8 +912,8 @@ similar(const char *a, const char *b, size_t len)
/* Exit with cleanup. */
-void
-my_exit(int status)
+static void
+my_cleanup(void)
{
Unlink(TMPINNAME);
if (!toutkeep) {
@@ -922,5 +923,20 @@ my_exit(int status)
Unlink(TMPREJNAME);
}
Unlink(TMPPATNAME);
+}
+
+
+void
+my_exit(int status)
+{
+ my_cleanup();
exit(status);
}
+
+void
+my_sig_exit(int signo)
+{
+ my_cleanup();
+ (void)raise_default_signal(signo);
+ _exit(1);
+}
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 3a44116e5d0..f3ee4134a4c 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.22 2006/04/09 19:12:17 christos Exp $ */
+/* $NetBSD: util.c,v 1.23 2007/10/14 04:54:34 lukem Exp $ */
/*
* Copyright (c) 1988, Larry Wall
@@ -24,7 +24,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: util.c,v 1.22 2006/04/09 19:12:17 christos Exp $");
+__RCSID("$NetBSD: util.c,v 1.23 2007/10/14 04:54:34 lukem Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -334,10 +334,10 @@ set_signals(int reset)
if (!reset) {
hupval = signal(SIGHUP, SIG_IGN);
if (hupval != SIG_IGN)
- hupval = my_exit;
+ hupval = my_sig_exit;
intval = signal(SIGINT, SIG_IGN);
if (intval != SIG_IGN)
- intval = my_exit;
+ intval = my_sig_exit;
}
Signal(SIGHUP, hupval);
Signal(SIGINT, intval);