Browse Source

Remove unused wait4pid function

develop
Damien Goutte-Gattat 8 years ago
parent
commit
aeaec8d36f
  1. 48
      src/wait4pid.c
  2. 3
      src/wait4pid.h

48
src/wait4pid.c

@ -98,11 +98,6 @@ wait4pid_init(void)
return 0;
}
struct __attribute__ ((__packed__)) cn_proc_msg {
struct cn_msg msg;
struct proc_event evt;
};
static int
do_recv(int sock, void *buf, size_t len, int flags)
{
@ -115,37 +110,15 @@ do_recv(int sock, void *buf, size_t len, int flags)
return ret;
}
int
wait4pid(pid_t pid)
{
int ec;
struct cn_proc_msg *payload;
char buf[NLMSG_SPACE(sizeof(struct cn_proc_msg))];
if ( ! listener_set && wait4pid_init() == -1 )
return -1;
if ( kill(pid, 0) == -1 && errno == ESRCH )
return -1;
while ( do_recv(sock, buf, sizeof(buf), 0) > 0 ) {
payload = (struct cn_proc_msg *) NLMSG_DATA(buf);
if ( payload->evt.what == PROC_EVENT_EXIT
&& payload->evt.event_data.exit.process_pid == pid ) {
ec = payload->evt.event_data.exit.exit_code / 256;
break;
}
}
return ec;
}
int
wait4all(pid_t *pids, size_t len)
{
int ec, nproc, i;
struct cn_proc_msg *payload;
char buf[NLMSG_SPACE(sizeof(struct cn_proc_msg))];
struct __attribute__ ((__packed__ )) payload_t {
struct cn_msg msg;
struct proc_event evt;
} *payload;
char buf[NLMSG_SPACE(sizeof(struct payload_t))];
if ( ! listener_set && wait4pid_init() == -1 )
return -1;
@ -160,7 +133,7 @@ wait4all(pid_t *pids, size_t len)
if ( do_recv(sock, buf, sizeof(buf), 0) <= 0 )
return -1;
payload = (struct cn_proc_msg *) NLMSG_DATA(buf);
payload = (struct payload_t *) NLMSG_DATA(buf);
if ( payload->evt.what != PROC_EVENT_EXIT )
continue;
@ -182,15 +155,6 @@ wait4all(pid_t *pids, size_t len)
#include <signal.h>
int
wait4pid(pid_t pid)
{
while ( kill(pid, 0) != -1 || errno != ESRCH )
sleep(1);
return 0;
}
int
wait4all(pid_t *pids, size_t len)
{

3
src/wait4pid.h

@ -25,9 +25,6 @@
extern "C" {
#endif
int
wait4pid(pid_t);
int
wait4all(pid_t *, size_t);

Loading…
Cancel
Save