blob: 8eb73e003a65e3cb40abdc3c47371084522b9864 [file] [log] [blame]
Rich Felkerc97f0d92011-05-28 18:36:30 -04001#ifndef _SPAWN_H
2#define _SPAWN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
Rich Felker455f9682012-09-08 17:14:52 -04008#include <features.h>
Rich Felker400c5e52012-09-06 22:44:55 -04009
Rich Felkerc97f0d92011-05-28 18:36:30 -040010#define __NEED_mode_t
11#define __NEED_pid_t
12#define __NEED_sigset_t
13
14#include <bits/alltypes.h>
15
16struct sched_param;
17
18#define POSIX_SPAWN_RESETIDS 1
19#define POSIX_SPAWN_SETPGROUP 2
20#define POSIX_SPAWN_SETSIGDEF 4
21#define POSIX_SPAWN_SETSIGMASK 8
22#define POSIX_SPAWN_SETSCHEDPARAM 16
23#define POSIX_SPAWN_SETSCHEDULER 32
Rich Felker77e895d2017-04-22 20:40:09 -040024#define POSIX_SPAWN_USEVFORK 64
Rich Felkerbb439bb2017-04-22 18:39:40 -040025#define POSIX_SPAWN_SETSID 128
Rich Felkerc97f0d92011-05-28 18:36:30 -040026
27typedef struct {
28 int __flags;
29 pid_t __pgrp;
30 sigset_t __def, __mask;
Rich Felkerfe61a7a2018-09-10 16:13:29 -040031 int __prio, __pol;
32 void *__fn;
33 char __pad[64-sizeof(void *)];
Rich Felkerc97f0d92011-05-28 18:36:30 -040034} posix_spawnattr_t;
35
36typedef struct {
37 int __pad0[2];
38 void *__actions;
39 int __pad[16];
40} posix_spawn_file_actions_t;
41
Rich Felker400c5e52012-09-06 22:44:55 -040042int posix_spawn(pid_t *__restrict, const char *__restrict, const posix_spawn_file_actions_t *,
43 const posix_spawnattr_t *__restrict, char *const *__restrict, char *const *__restrict);
44int posix_spawnp(pid_t *__restrict, const char *__restrict, const posix_spawn_file_actions_t *,
45 const posix_spawnattr_t *__restrict, char *const *__restrict, char *const *__restrict);
Rich Felkerc97f0d92011-05-28 18:36:30 -040046
47int posix_spawnattr_init(posix_spawnattr_t *);
48int posix_spawnattr_destroy(posix_spawnattr_t *);
49
50int posix_spawnattr_setflags(posix_spawnattr_t *, short);
Rich Felker400c5e52012-09-06 22:44:55 -040051int posix_spawnattr_getflags(const posix_spawnattr_t *__restrict, short *__restrict);
Rich Felkerc97f0d92011-05-28 18:36:30 -040052
53int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
Rich Felker400c5e52012-09-06 22:44:55 -040054int posix_spawnattr_getpgroup(const posix_spawnattr_t *__restrict, pid_t *__restrict);
Rich Felkerc97f0d92011-05-28 18:36:30 -040055
Rich Felker400c5e52012-09-06 22:44:55 -040056int posix_spawnattr_setsigmask(posix_spawnattr_t *__restrict, const sigset_t *__restrict);
57int posix_spawnattr_getsigmask(const posix_spawnattr_t *__restrict, sigset_t *__restrict);
Rich Felkerc97f0d92011-05-28 18:36:30 -040058
Rich Felker400c5e52012-09-06 22:44:55 -040059int posix_spawnattr_setsigdefault(posix_spawnattr_t *__restrict, const sigset_t *__restrict);
60int posix_spawnattr_getsigdefault(const posix_spawnattr_t *__restrict, sigset_t *__restrict);
Rich Felkerc97f0d92011-05-28 18:36:30 -040061
Rich Felker1e21e782012-11-11 15:38:04 -050062int posix_spawnattr_setschedparam(posix_spawnattr_t *__restrict, const struct sched_param *__restrict);
63int posix_spawnattr_getschedparam(const posix_spawnattr_t *__restrict, struct sched_param *__restrict);
Rich Felker1c322f22012-11-27 09:44:30 -050064int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
65int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *__restrict, int *__restrict);
Rich Felker1e21e782012-11-11 15:38:04 -050066
Rich Felkerc97f0d92011-05-28 18:36:30 -040067int posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
68int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
69
Rich Felker400c5e52012-09-06 22:44:55 -040070int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict, int, const char *__restrict, int, mode_t);
Rich Felkerc97f0d92011-05-28 18:36:30 -040071int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
72int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
73
Rich Felker74244e52019-08-30 16:21:36 -040074#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
75int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *__restrict, const char *__restrict);
76int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, int);
77#endif
78
Rich Felkerc97f0d92011-05-28 18:36:30 -040079#ifdef __cplusplus
80}
81#endif
82
83#endif