1 #pragma once
2 
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 #include <features.h>
8 
9 #define __NEED_mode_t
10 #define __NEED_pid_t
11 #define __NEED_sigset_t
12 
13 #include <bits/alltypes.h>
14 
15 struct sched_param;
16 
17 #define POSIX_SPAWN_RESETIDS 1
18 #define POSIX_SPAWN_SETPGROUP 2
19 #define POSIX_SPAWN_SETSIGDEF 4
20 #define POSIX_SPAWN_SETSIGMASK 8
21 #define POSIX_SPAWN_SETSCHEDPARAM 16
22 #define POSIX_SPAWN_SETSCHEDULER 32
23 
24 typedef struct {
25     int __flags;
26     pid_t __pgrp;
27     sigset_t __def, __mask;
28     int __prio, __pol, __pad[16];
29 } posix_spawnattr_t;
30 
31 typedef struct {
32     int __pad0[2];
33     void* __actions;
34     int __pad[16];
35 } posix_spawn_file_actions_t;
36 
37 int posix_spawn(pid_t* __restrict, const char* __restrict, const posix_spawn_file_actions_t*,
38                 const posix_spawnattr_t* __restrict, char* const* __restrict,
39                 char* const* __restrict);
40 int posix_spawnp(pid_t* __restrict, const char* __restrict, const posix_spawn_file_actions_t*,
41                  const posix_spawnattr_t* __restrict, char* const* __restrict,
42                  char* const* __restrict);
43 
44 int posix_spawnattr_init(posix_spawnattr_t*);
45 int posix_spawnattr_destroy(posix_spawnattr_t*);
46 
47 int posix_spawnattr_setflags(posix_spawnattr_t*, short);
48 int posix_spawnattr_getflags(const posix_spawnattr_t* __restrict, short* __restrict);
49 
50 int posix_spawnattr_setpgroup(posix_spawnattr_t*, pid_t);
51 int posix_spawnattr_getpgroup(const posix_spawnattr_t* __restrict, pid_t* __restrict);
52 
53 int posix_spawnattr_setsigmask(posix_spawnattr_t* __restrict, const sigset_t* __restrict);
54 int posix_spawnattr_getsigmask(const posix_spawnattr_t* __restrict, sigset_t* __restrict);
55 
56 int posix_spawnattr_setsigdefault(posix_spawnattr_t* __restrict, const sigset_t* __restrict);
57 int posix_spawnattr_getsigdefault(const posix_spawnattr_t* __restrict, sigset_t* __restrict);
58 
59 int posix_spawnattr_setschedparam(posix_spawnattr_t* __restrict,
60                                   const struct sched_param* __restrict);
61 int posix_spawnattr_getschedparam(const posix_spawnattr_t* __restrict,
62                                   struct sched_param* __restrict);
63 int posix_spawnattr_setschedpolicy(posix_spawnattr_t*, int);
64 int posix_spawnattr_getschedpolicy(const posix_spawnattr_t* __restrict, int* __restrict);
65 
66 int posix_spawn_file_actions_init(posix_spawn_file_actions_t*);
67 int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t*);
68 
69 int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* __restrict, int,
70                                      const char* __restrict, int, mode_t);
71 int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t*, int);
72 int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t*, int, int);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77