ado@elsie.nci.nih.gov (Arthur David Olson) (11/02/90)
So there I was trying to ntpdc umd1.umd.edu and having the program hang. As it turns out, on SunOS 4.1 systems, if you get a signal as a result of a previous alarm() call during a recvfrom() call, the recvfrom() is restarted. The attached change arranges things so that the alarm signal interrupts the recvfrom(), resulting in a bailout rather than a hang. -- Arthur David Olson ado@elsie.nci.nih.gov ADO and Elsie are Ampex and Borden trademarks SCCS/s.ntpdc.c: 1.1 vs. 1.2 *** 1.1/ntpdc.c Thu Nov 1 21:37:36 1990 --- 1.2/ntpdc.c Thu Nov 1 21:37:36 1990 *************** *** 192,198 **** --- 192,209 ---- FD_SET(s, &bits); shorttime.tv_sec = 0; shorttime.tv_usec = STIME; + #ifdef SA_INTERRUPT + { + static struct sigaction sa; + + sa.sa_handler = timeout; + sa.sa_flags = SA_INTERRUPT; + (void) sigaction(SIGALRM, &sa, (struct sigaction *) NULL); + } + #endif /* defined SA_INTERRUPT */ + #ifndef SA_INTERRUPT (void) signal(SIGALRM, timeout); + #endif /* !defined SA_INTERRUPT */ (void) alarm(WTIME); timedout = 0; while ((first || replies) &&