Subject: bin/6051: [PATCH] Adventure signal handling
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm@octomino.demon.co.uk>
List: netbsd-bugs
Date: 08/26/1998 20:50:15
>Number: 6051
>Category: bin
>Synopsis: [PATCH] Adventure signal handling
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Aug 26 14:05:01 1998
>Last-Modified:
>Originator: Joseph Samuel Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release: NetBSD-current of 1998-08-24
>Environment:
[
System: Linux octomino 2.0.35 #1 Wed Aug 12 15:54:21 UTC 1998 i586 unknown
Architecture: i586
]
>Description:
Adventure _nearly_ gets signal handling right (in terms of not using
functions that are not async-safe from the signal handler). Given
this, it is easy to make it entirely correct, as done by the patch
below, by making the variable assigned to of type volatile
sig_atomic_t (rather than non-volatile int) and only assigning to it
(rather than incrementing it - see ISO C subclause 7.7.1.1).
>How-To-Repeat:
>Fix:
diff -ruN adventure/hdr.h adventure+3/hdr.h
--- adventure/hdr.h Sat Oct 11 11:49:20 1997
+++ adventure+3/hdr.h Wed Aug 26 20:40:34 1998
@@ -55,8 +55,10 @@
/* hdr.h: included by c advent files */
+#include <signal.h>
+
int datfd; /* message file descriptor */
-int delhit;
+volatile sig_atomic_t delhit;
int yea;
extern char data_file[]; /* Virtual data file */
diff -ruN adventure/init.c adventure+3/init.c
--- adventure/init.c Tue Aug 25 11:05:16 1998
+++ adventure+3/init.c Wed Aug 26 20:41:47 1998
@@ -219,7 +219,7 @@
trapdel(n) /* come here if he hits a del */
int n;
{
- delhit++; /* main checks, treats as QUIT */
+ delhit = 1; /* main checks, treats as QUIT */
signal(SIGINT, trapdel);/* catch subsequent DELs */
}
>Audit-Trail:
>Unformatted: