ping: Do not use signals

This commit is contained in:
Sebastian Huber 2022-06-10 08:00:09 +02:00
parent cdb5ac55c6
commit 4ca39ca3fc

View File

@ -307,7 +307,9 @@ main(int argc, char *const *argv)
#endif #endif
struct sockaddr_in *to; struct sockaddr_in *to;
double t; double t;
#ifndef __rtems__
u_long alarmtimeout; u_long alarmtimeout;
#endif /* __rtems__ */
long ltmp; long ltmp;
int almost_done, ch, df, hold, i, icmp_len, mib[4], preload; int almost_done, ch, df, hold, i, icmp_len, mib[4], preload;
int ssend_errno, srecv_errno, tos, ttl; int ssend_errno, srecv_errno, tos, ttl;
@ -370,7 +372,9 @@ main(int argc, char *const *argv)
err(EX_OSERR, "srecv socket"); err(EX_OSERR, "srecv socket");
} }
#ifndef __rtems__
alarmtimeout = df = preload = tos = 0; alarmtimeout = df = preload = tos = 0;
#endif /* __rtems__ */
outpack = outpackhdr + sizeof(struct ip); outpack = outpackhdr + sizeof(struct ip);
while ((ch = getopt(argc, argv, while ((ch = getopt(argc, argv,
@ -572,6 +576,7 @@ main(int argc, char *const *argv)
mttl = ltmp; mttl = ltmp;
options |= F_MTTL; options |= F_MTTL;
break; break;
#ifndef __rtems__
case 't': case 't':
alarmtimeout = strtoul(optarg, &ep, 0); alarmtimeout = strtoul(optarg, &ep, 0);
if ((alarmtimeout < 1) || (alarmtimeout == ULONG_MAX)) if ((alarmtimeout < 1) || (alarmtimeout == ULONG_MAX))
@ -582,6 +587,7 @@ main(int argc, char *const *argv)
optarg, MAXALARM); optarg, MAXALARM);
alarm((int)alarmtimeout); alarm((int)alarmtimeout);
break; break;
#endif /* __rtems__ */
case 'v': case 'v':
options |= F_VERBOSE; options |= F_VERBOSE;
break; break;
@ -1518,8 +1524,10 @@ static void
finish(void) finish(void)
{ {
#ifndef __rtems__
(void)signal(SIGINT, SIG_IGN); (void)signal(SIGINT, SIG_IGN);
(void)signal(SIGALRM, SIG_IGN); (void)signal(SIGALRM, SIG_IGN);
#endif /* __rtems__ */
(void)putchar('\n'); (void)putchar('\n');
(void)fflush(stdout); (void)fflush(stdout);
(void)printf("--- %s ping statistics ---\n", hostname); (void)printf("--- %s ping statistics ---\n", hostname);