Browse Source

Handle interrupted send(2) call

develop
Damien Goutte-Gattat 8 years ago
parent
commit
ca53be2414
  1. 39
      src/wait4pid.c

39
src/wait4pid.c

@ -34,6 +34,31 @@
int sock = 0;
int listener_set = 0;
static ssize_t
do_send(int sock, const void *buf, size_t len, int flags)
{
int ret;
do {
ret = send(sock, buf, len, flags);
} while ( ret == -1 && errno == EINTR );
return ret;
}
static int
do_recv(int sock, void *buf, size_t len, int flags)
{
int ret;
do {
ret = recv(sock, buf, len, flags);
} while ( ret == -1 && errno == EINTR );
return ret;
}
static int
set_proc_listen(int sock, int enable)
{
@ -58,7 +83,7 @@ set_proc_listen(int sock, int enable)
payload->msg.len = sizeof(payload->op);
payload->op = enable ? PROC_CN_MCAST_LISTEN : PROC_CN_MCAST_IGNORE;
return send(sock, hdr, NLMSG_SPACE(sizeof(*payload)), 0);
return do_send(sock, hdr, NLMSG_SPACE(sizeof(*payload)), 0);
}
static void
@ -102,18 +127,6 @@ wait4pid_init(void)
return 0;
}
static int
do_recv(int sock, void *buf, size_t len, int flags)
{
int ret;
do {
ret = recv(sock, buf, len, flags);
} while ( ret == -1 && errno == EINTR );
return ret;
}
int
wait4all(pid_t *pids, size_t len)
{

Loading…
Cancel
Save