summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/os/waitid.h
blob: 9e1fd6be7d5076f82d6629b1cb8645a30a809bca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_WAITID_H
#define NETDATA_WAITID_H

#include "config.h"
#include <sys/types.h>
#include <signal.h>

#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif

#ifndef WNOWAIT
#define WNOWAIT 0x01000000
#endif

#ifndef WEXITED
#define WEXITED 4
#endif

#if !defined(HAVE_WAITID)
typedef enum
{
    P_ALL,     /* Wait for any child.  */
    P_PID,     /* Wait for specified process.  */
    P_PGID,    /* Wait for members of process group.  */
    P_PIDFD,   /* Wait for the child referred by the PID file descriptor.  */
} idtype_t;

struct pid_status {
    pid_t pid;
    int status;
};

#if defined(OS_WINDOWS) && !defined(__CYGWIN__)
typedef uint32_t id_t;
typedef struct {
    int si_code;	/* Signal code.  */
    int si_status;	/* Exit value or signal.  */
    pid_t si_pid;	/* Sending process ID.  */
} siginfo_t;
#endif
#endif

int os_waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);

#endif //NETDATA_WAITID_H