[2242] in Kerberos-V5-bugs
krb5b7: telnet: use POSIX signal semantics when they're available
daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Tue Sep 17 17:15:58 1996
Date: Tue, 17 Sep 1996 17:15:57 -0400
From: "Jonathan I. Kamens" <jik@jik.tiac.net>
To: krb5-bugs@MIT.EDU, kerberos@MIT.EDU
telnet/sys_bsd.c needs to use sigaction() rather than signal() to set
up signal handlers with POSIX_SIGNALS is defined, so that the
SA_ONESHOT bit won't be set on the resulting handlers, so that they
won't be deinstalled after the first time they're invoked.
Patch:
--- telnet/sys_bsd.c 1996/09/17 20:03:54 1.1
+++ telnet/sys_bsd.c 1996/09/17 20:04:28 1.2
@@ -47,6 +47,9 @@
#include <sys/select.h>
#endif
#include <signal.h>
+#ifdef POSIX_SIGNALS
+#include <unistd.h>
+#endif /* POSIX_SIGNALS */
#include <errno.h>
#include <arpa/telnet.h>
@@ -67,6 +70,30 @@
#ifdef SIGINFO
extern SIG_FUNC_RET ayt_status();
#endif
+
+#ifdef POSIX_SIGNALS
+static struct sigaction new_sa_rec, old_sa_rec;
+
+#ifdef SA_INTERRUPT
+#define SIGACTION_INTERRUPT SA_INTERRUPT
+#else
+#define SIGACTION_INTERRUPT 0
+#endif
+
+#ifdef SA_NOMASK
+#define SIGACTION_NOMASK SA_NOMASK
+#else
+#define SIGACTION_NOMASK 0
+#endif
+
+#define signal(sig, func) ((new_sa_rec.sa_handler = func), \
+ sigemptyset(&new_sa_rec.sa_mask), \
+ (new_sa_rec.sa_flags = SIGACTION_INTERRUPT | \
+ SIGACTION_NOMASK), \
+ sigaction(sig, &new_sa_rec, &old_sa_rec), \
+ old_sa_rec.sa_handler)
+
+#endif /* POSIX_SIGNALS */
int
tout, /* Output file descriptor */