Changeset View
Changeset View
Standalone View
Standalone View
head/sbin/ping/ping.c
Show First 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | #endif /*IPSEC*/ | ||||
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)) | ||||
errx(EX_USAGE, "invalid timeout: `%s'", | errx(EX_USAGE, "invalid timeout: `%s'", | ||||
optarg); | optarg); | ||||
if (alarmtimeout > MAXALARM) | if (alarmtimeout > MAXALARM) | ||||
errx(EX_USAGE, "invalid timeout: `%s' > %d", | errx(EX_USAGE, "invalid timeout: `%s' > %d", | ||||
optarg, MAXALARM); | optarg, MAXALARM); | ||||
alarm((int)alarmtimeout); | { | ||||
struct itimerval itv; | |||||
timerclear(&itv.it_interval); | |||||
timerclear(&itv.it_value); | |||||
itv.it_value.tv_sec = (time_t)alarmtimeout; | |||||
if (setitimer(ITIMER_REAL, &itv, NULL) != 0) | |||||
err(1, "setitimer"); | |||||
} | |||||
break; | break; | ||||
case 'v': | case 'v': | ||||
options |= F_VERBOSE; | options |= F_VERBOSE; | ||||
break; | break; | ||||
case 'W': /* wait ms for answer */ | case 'W': /* wait ms for answer */ | ||||
t = strtod(optarg, &ep); | t = strtod(optarg, &ep); | ||||
if (*ep || ep == optarg || t > (double)INT_MAX) | if (*ep || ep == optarg || t > (double)INT_MAX) | ||||
errx(EX_USAGE, "invalid timing interval: `%s'", | errx(EX_USAGE, "invalid timing interval: `%s'", | ||||
▲ Show 20 Lines • Show All 1,250 Lines • Show Last 20 Lines |