From owner-freebsd-current Sat Aug 23 00:19:59 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id AAA27377 for current-outgoing; Sat, 23 Aug 1997 00:19:59 -0700 (PDT) Received: from scanner.worldgate.com (scanner.worldgate.com [198.161.84.3]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id AAA27371; Sat, 23 Aug 1997 00:19:53 -0700 (PDT) Received: from znep.com (uucp@localhost) by scanner.worldgate.com (8.8.5/8.8.5) with UUCP id BAA14729; Sat, 23 Aug 1997 01:19:44 -0600 (MDT) Received: from localhost (marcs@localhost) by alive.znep.com (8.7.5/8.7.3) with SMTP id BAA07684; Sat, 23 Aug 1997 01:19:46 -0600 (MDT) Date: Sat, 23 Aug 1997 01:19:45 -0600 (MDT) From: Marc Slemko To: Sean Eric Fagan cc: julian@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: I've broken ping In-Reply-To: <199707120707.AAA23391@kithrup.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Sat, 12 Jul 1997, Sean Eric Fagan wrote: > >(or if sean can post the patch someone else can check it in) > >(to 2.2 and 3.0) (don;t you have commit privs sean?) > > Yeah, I have patches, but I was hoping you'd be able to test it more > extensively than I could :). > > I can check it in tomorrow, otherwise. > > For the curious, the patches are below. I'm going to bed now :). Running under 2.2-stable from a week or two ago, both the 2.2 and -current ping are still broken. I am seeing it hang in pr_addr if the reverse isn't resolvable; ^C wont kill it because it appears like a function call is being restarted. I am confused about why this is happening. ISTR some changes in FreeBSD WRT this that I haven't had time to follow. Changing the sigaction() back to a signal() fixes this particular case. The signal() man page says function calls will be restarted, but the sigaction() man page implies they won't without SA_RESTART. That follows with what I am aware that recent BSD code does. It doesn't seem to fit with what I am seeing. > > Index: ping.c > =================================================================== > RCS file: /home/ncvs/src/sbin/ping/ping.c,v > retrieving revision 1.23 > diff -u -r1.23 ping.c > --- ping.c 1997/07/09 20:33:58 1.23 > +++ ping.c 1997/07/12 03:55:41 > @@ -423,8 +423,19 @@ > else > (void)printf("PING %s: %d data bytes\n", hostname, datalen); > > - (void)signal(SIGINT, stopit); > - (void)signal(SIGALRM, catcher); > + si_sa.sa_handler = stopit; > + sigemptyset(&si_sa.sa_mask); > + si_sa.sa_flags = 0; > + if (sigaction(SIGINT, &si_sa, 0) == -1) { > + err(EX_OSERR, "sigaction SIGINT"); > + } > + > + si_sa.sa_handler = catcher; > + sigemptyset(&si_sa.sa_mask); > + si_sa.sa_flags = 0; > + if (sigaction(SIGALRM, &si_sa, 0) == -1) { > + err(EX_OSERR, "sigaction SIGALRM"); > + } > > /* > * Use sigaction instead of signal() to get unambiguous semantics > @@ -508,9 +519,17 @@ > catcher(int sig) > { > int waittime; > + struct sigaction si_sa; > > pinger(); > - (void)signal(SIGALRM, catcher); > + > + si_sa.sa_handler = catcher; > + sigemptyset(&si_sa.sa_mask); > + si_sa.sa_flags = 0; > + if (sigaction(SIGALRM, &si_sa, 0) == -1) { > + err(EX_OSERR, "sigaction"); > + } > + > if (!npackets || ntransmitted < npackets) > alarm((u_int)interval); > else { > @@ -520,7 +539,9 @@ > waittime = 1; > } else > waittime = MAXWAIT; > - (void)signal(SIGALRM, stopit); > + finish_up = 1; > + si_sa.sa_handler = stopit; > + (void)sigaction(SIGALRM, &si_sa, 0); > (void)alarm((u_int)waittime); > } > } >