Browse Source

Use nanosleep(2) instead of sleep(3)

The nanosleep(2) system call can be safely mixed with alarm(2),
according to POSIX and contrary to sleep(3).
develop
Damien Goutte-Gattat 8 years ago
parent
commit
9a8d746de5
  1. 4
      src/wait4pid.c

4
src/wait4pid.c

@ -153,12 +153,14 @@ wait4all(pid_t *pids, size_t len)
#else /* HAVE_LINUX_NETLINK_H */
#include <time.h>
#include <signal.h>
int
wait4all(pid_t *pids, size_t len)
{
int nproc, i;
struct timespec ts = { 1, 0 };
nproc = len;
while ( nproc > 0 ) {
@ -172,7 +174,7 @@ wait4all(pid_t *pids, size_t len)
}
}
sleep(1);
nanosleep(&ts, NULL);
}
return 0;

Loading…
Cancel
Save