Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit/TEST Make signal handler safe. From Michael Knu...
details: https://anonhg.NetBSD.org/src/rev/6520a84e4a70
branches: trunk
changeset: 580972:6520a84e4a70
user: christos <christos%NetBSD.org@localhost>
date: Wed May 18 00:50:24 2005 +0000
description:
Make signal handler safe. From Michael Knudsen, many thanks.
diffstat:
lib/libedit/TEST/test.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diffs (51 lines):
diff -r 7b44f93a4752 -r 6520a84e4a70 lib/libedit/TEST/test.c
--- a/lib/libedit/TEST/test.c Wed May 18 00:31:32 2005 +0000
+++ b/lib/libedit/TEST/test.c Wed May 18 00:50:24 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: test.c,v 1.15 2003/12/08 12:03:01 lukem Exp $ */
+/* $NetBSD: test.c,v 1.16 2005/05/18 00:50:24 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: test.c,v 1.15 2003/12/08 12:03:01 lukem Exp $");
+__RCSID("$NetBSD: test.c,v 1.16 2005/05/18 00:50:24 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -63,6 +63,8 @@
static int continuation = 0;
static EditLine *el = NULL;
+volatile sig_atomic_t gotsig = 0;
+
static u_char complete(EditLine *, int);
int main(int, char **);
static char *prompt(EditLine *);
@@ -80,9 +82,7 @@
static void
sig(int i)
{
-
- (void) fprintf(stderr, "Got signal %d.\n", i);
- el_reset(el);
+ gotsig = i;
}
static unsigned char
@@ -185,6 +185,12 @@
(li->cursor >= li->lastchar) ? "" : li->cursor);
#endif
+ if (gotsig) {
+ (void) fprintf(stderr, "Got signal %d.\n", gotsig);
+ gotsig = 0;
+ el_reset(el);
+ }
+
if (!continuation && num == 1)
continue;
Home |
Main Index |
Thread Index |
Old Index