Serenity Operating System
at master 78 lines 2.8 kB view raw
1/* 2 * Copyright (c) 2020, Nico Weber <thakis@chromium.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7/* posix_spawn and friends 8 * 9 * values from POSIX standard unix specification 10 * 11 * https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/spawn.h.html 12 */ 13 14#pragma once 15 16#include <sched.h> 17#include <signal.h> 18#include <sys/cdefs.h> 19#include <sys/types.h> 20 21__BEGIN_DECLS 22 23enum { 24 POSIX_SPAWN_RESETIDS = 1 << 0, 25 POSIX_SPAWN_SETPGROUP = 1 << 1, 26 27 POSIX_SPAWN_SETSCHEDPARAM = 1 << 2, 28 POSIX_SPAWN_SETSCHEDULER = 1 << 3, 29 30 POSIX_SPAWN_SETSIGDEF = 1 << 4, 31 POSIX_SPAWN_SETSIGMASK = 1 << 5, 32 33 POSIX_SPAWN_SETSID = 1 << 6, 34}; 35 36#define POSIX_SPAWN_SETSID POSIX_SPAWN_SETSID 37 38struct posix_spawn_file_actions_state; 39typedef struct { 40 struct posix_spawn_file_actions_state* state; 41} posix_spawn_file_actions_t; 42 43typedef struct { 44 short flags; 45 pid_t pgroup; 46 struct sched_param schedparam; 47 int schedpolicy; 48 sigset_t sigdefault; 49 sigset_t sigmask; 50} posix_spawnattr_t; 51 52int posix_spawn(pid_t*, char const*, posix_spawn_file_actions_t const*, posix_spawnattr_t const*, char* const argv[], char* const envp[]); 53int posix_spawnp(pid_t*, char const*, posix_spawn_file_actions_t const*, posix_spawnattr_t const*, char* const argv[], char* const envp[]); 54 55int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t*, char const*); 56int posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t*, int); 57int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t*, int); 58int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t*, int old_fd, int new_fd); 59int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t*, int fd, char const*, int flags, mode_t); 60int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t*); 61int posix_spawn_file_actions_init(posix_spawn_file_actions_t*); 62 63int posix_spawnattr_destroy(posix_spawnattr_t*); 64int posix_spawnattr_getflags(posix_spawnattr_t const*, short*); 65int posix_spawnattr_getpgroup(posix_spawnattr_t const*, pid_t*); 66int posix_spawnattr_getschedparam(posix_spawnattr_t const*, struct sched_param*); 67int posix_spawnattr_getschedpolicy(posix_spawnattr_t const*, int*); 68int posix_spawnattr_getsigdefault(posix_spawnattr_t const*, sigset_t*); 69int posix_spawnattr_getsigmask(posix_spawnattr_t const*, sigset_t*); 70int posix_spawnattr_init(posix_spawnattr_t*); 71int posix_spawnattr_setflags(posix_spawnattr_t*, short); 72int posix_spawnattr_setpgroup(posix_spawnattr_t*, pid_t); 73int posix_spawnattr_setschedparam(posix_spawnattr_t*, const struct sched_param*); 74int posix_spawnattr_setschedpolicy(posix_spawnattr_t*, int); 75int posix_spawnattr_setsigdefault(posix_spawnattr_t*, sigset_t const*); 76int posix_spawnattr_setsigmask(posix_spawnattr_t*, sigset_t const*); 77 78__END_DECLS