Kernel+LibC: Share definitions for sys/wait.h

This commit is contained in:
Andreas Kling 2021-08-14 18:18:30 +02:00
parent 661bd992b0
commit 6f78377864
3 changed files with 40 additions and 36 deletions

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <Kernel/API/POSIX/sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define WEXITSTATUS(status) (((status)&0xff00) >> 8)
#define WSTOPSIG(status) WEXITSTATUS(status)
#define WTERMSIG(status) ((status)&0x7f)
#define WIFEXITED(status) (WTERMSIG(status) == 0)
#define WIFSTOPPED(status) (((status)&0xff) == 0x7f)
#define WIFSIGNALED(status) (((char)(((status)&0x7f) + 1) >> 1) > 0)
#define WNOHANG 1
#define WUNTRACED 2
#define WSTOPPED WUNTRACED
#define WEXITED 4
#define WCONTINUED 8
#define WNOWAIT 0x1000000
typedef enum {
P_ALL = 1,
P_PID,
P_PGID
} idtype_t;
#ifdef __cplusplus
}
#endif

View file

@ -19,6 +19,7 @@
#include <Kernel/API/POSIX/sys/socket.h>
#include <Kernel/API/POSIX/sys/stat.h>
#include <Kernel/API/POSIX/sys/un.h>
#include <Kernel/API/POSIX/sys/wait.h>
#include <Kernel/API/POSIX/termios.h>
#include <Kernel/API/POSIX/time.h>
@ -63,13 +64,6 @@ enum {
PERF_EVENT_SIGNPOST = 32768,
};
#define WNOHANG 1
#define WUNTRACED 2
#define WSTOPPED WUNTRACED
#define WEXITED 4
#define WCONTINUED 8
#define WNOWAIT 0x1000000
#define R_OK 4
#define W_OK 2
#define X_OK 1
@ -141,12 +135,6 @@ struct timeval {
suseconds_t tv_usec;
};
typedef enum {
P_ALL = 1,
P_PID,
P_PGID
} idtype_t;
#define UTSNAME_ENTRY_LEN 65
struct utsname {

View file

@ -6,32 +6,11 @@
#pragma once
#include <signal.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <Kernel/API/POSIX/signal.h>
#include <Kernel/API/POSIX/sys/wait.h>
__BEGIN_DECLS
#define WEXITSTATUS(status) (((status)&0xff00) >> 8)
#define WSTOPSIG(status) WEXITSTATUS(status)
#define WTERMSIG(status) ((status)&0x7f)
#define WIFEXITED(status) (WTERMSIG(status) == 0)
#define WIFSTOPPED(status) (((status)&0xff) == 0x7f)
#define WIFSIGNALED(status) (((char)(((status)&0x7f) + 1) >> 1) > 0)
#define WNOHANG 1
#define WUNTRACED 2
#define WSTOPPED WUNTRACED
#define WEXITED 4
#define WCONTINUED 8
#define WNOWAIT 0x1000000
typedef enum {
P_ALL = 1,
P_PID,
P_PGID
} idtype_t;
pid_t waitpid(pid_t, int* wstatus, int options);
pid_t wait(int* wstatus);
int waitid(idtype_t idtype, id_t id, siginfo_t* infop, int options);