From d368b2e8b6245ab51887cbc0619eb5612abe6464 Mon Sep 17 00:00:00 2001 From: Philip Guenther Date: Sun, 30 Aug 2015 05:45:44 +0000 Subject: Use nanosleep instead of sleep to avoid the extra layer and simplify later symbol hiding ok w/tweak deraadt@ --- lib/libc/net/rcmd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 5ef44040019..600565a2359 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -66,7 +67,8 @@ rcmd_af(char **ahost, int porta, const char *locuser, const char *remuser, struct sockaddr_storage from; sigset_t oldmask, mask; pid_t pid; - int s, lport, timo; + int s, lport; + struct timespec timo; char c, *p; int refused; in_port_t rport = porta; @@ -110,10 +112,11 @@ rcmd_af(char **ahost, int porta, const char *locuser, const char *remuser, r = res; refused = 0; + timespecclear(&timo); sigemptyset(&mask); sigaddset(&mask, SIGURG); sigprocmask(SIG_BLOCK, &mask, &oldmask); - for (timo = 1, lport = IPPORT_RESERVED - 1;;) { + for (timo.tv_sec = 1, lport = IPPORT_RESERVED - 1;;) { s = rresvport_af(&lport, r->ai_family); if (s < 0) { if (errno == EAGAIN) @@ -161,9 +164,9 @@ rcmd_af(char **ahost, int porta, const char *locuser, const char *remuser, (void)fprintf(stderr, "Trying %s...\n", hbuf); continue; } - if (refused && timo <= 16) { - (void)sleep(timo); - timo *= 2; + if (refused && timo.tv_sec <= 16) { + (void)nanosleep(&timo, NULL); + timo.tv_sec *= 2; r = res; refused = 0; continue; -- cgit v1.2.3