Browse Source

Add /proc fallback

On systems where netlink is not available, use the /proc
filesystem to regularly check for the presence of the
desired process.
develop
Damien Goutte-Gattat 8 years ago
parent
commit
3fd8d08aca
  1. 24
      src/wait4pid.c

24
src/wait4pid.c

@ -20,6 +20,8 @@
#include <config.h>
#endif
#ifdef HAVE_LINUX_NETLINK_H
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
@ -119,3 +121,25 @@ wait4pid(pid_t pid)
return ec;
}
#else /* HAVE_LINUX_NETLINK_H */
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
int
wait4pid(pid_t pid)
{
struct stat st_buf;
char path[20];
snprintf(path, sizeof(path), "/proc/%d", pid);
while ( stat(path, &st_buf) != -1 )
sleep(1);
return 0;
}
#endif /* ! HAVE_LINUX_NETLINK_H */
Loading…
Cancel
Save