[349] in Zephyr_Bugs
zhm
daemon@ATHENA.MIT.EDU (Marc Horowitz)
Wed Mar 11 23:36:01 1992
To: bug-sparc@Athena.MIT.EDU
Cc: bug-zephyr@Athena.MIT.EDU
Reply-To: Marc Horowitz <marc@MIT.EDU>
Date: Wed, 11 Mar 92 23:35:43 EST
From: Marc Horowitz <marc@Athena.MIT.EDU>
Several people have noticed that zhm "hangs" sometimes on the sun.
Today, warlord and I figured out why. The problem is that the sun has
POSIX signal semantics: namely, signals do *not* necessarily cause
syscalls to return EINTR; the syscall may restart without returning.
This was confusing zhm, which was, in fact, not returning until
another packet was received. The following patch uses sigaction() to
set SA_INTERRUPT on the socket.
For you sparc users out there, you can get a binary from
/afs/net.mit.edu/project/sunsrc/build/athena/project/zephyr/zhm/zhm.
Here's the patch:
*** /source/athena/athena.lib/zephyr/zhm/zhm.c Tue Jun 18 15:20:57 1991
--- zhm.c Wed Mar 11 22:30:27 1992
***************
*** 295,300 ****
--- 295,303 ----
struct servent *sp;
Code_t ret;
FILE *fp;
+ #ifdef SA_INTERRUPT
+ struct sigaction sa;
+ #endif
starttime = time((time_t *)0);
OPENLOG("hm", LOG_PID, LOG_DAEMON);
***************
*** 390,398 ****
--- 393,414 ----
send_boot_notice(HM_BOOT);
deactivated = 0;
+ #ifdef SA_INTERRUPT
+ /* POSIX semantics */
+ sa.sa_handler = set_sig_type;
+ sa.sa_mask = 0;
+ sa.sa_flags = SA_INTERRUPT;
+
+ sigaction(SIGHUP, &sa, 0);
+ sigaction(SIGALRM, &sa, 0);
+ sigaction(SIGTERM, &sa, 0);
+ #else
+ /* BSD semantics */
+
(void)signal (SIGHUP, set_sig_type);
(void)signal (SIGALRM, set_sig_type);
(void)signal (SIGTERM, set_sig_type);
+ #endif
}
void detach()
I believe this will continue to work on other platforms, but I have
not tested it. I have only lightly tested this on the sun, if I have
any other problems, you'll hear from me. :-)
Marc