Browse Source

Check error conditions

develop
Damien Goutte-Gattat 8 years ago
parent
commit
930ce3f85f
  1. 12
      src/wait4pid.c

12
src/wait4pid.c

@ -110,7 +110,14 @@ wait4pid(pid_t pid)
if ( ! listener_set && wait4pid_init() == -1 )
return -1;
while ( recv(sock, buf, sizeof(buf), 0) > 0 ) {
while ( 1 ) {
if ( (ec = recv(sock, buf, sizeof(buf), 0)) <= 0 ) {
if ( ec == -1 && errno == EINTR )
continue;
else
return -1;
}
payload = (struct payload_t *) NLMSG_DATA(buf);
if ( payload->evt.what == PROC_EVENT_EXIT
&& payload->evt.event_data.exit.process_pid == pid ) {
@ -139,7 +146,8 @@ wait4pid(pid_t pid)
while ( stat(path, &st_buf) != -1 )
sleep(1);
return 0;
/* Anything else than ENOENT is an error. */
return errno == ENOENT ? 0 : -1;
}
#endif /* ! HAVE_LINUX_NETLINK_H */
Loading…
Cancel
Save