xref: /haiku/headers/posix/spawn.h (revision 4bd0c1066b227cec4b79883bdef697c7a27f2e90)
1 /*
2  * Copyright 2017 Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the Haiku License.
4  */
5 #ifndef _SPAWN_H_
6 #define _SPAWN_H_
7 
8 
9 #include <sched.h>
10 #include <signal.h>
11 #include <stdint.h>
12 #include <sys/types.h>
13 
14 
15 /*
16  * Flags for spawn attributes.
17  */
18 #define POSIX_SPAWN_RESETIDS		0x01
19 #define POSIX_SPAWN_SETPGROUP		0x02
20 #if 0	/* Unimplemented flags: */
21 #define POSIX_SPAWN_SETSCHEDPARAM	0x04
22 #define POSIX_SPAWN_SETSCHEDULER	0x08
23 #endif	/* 0 */
24 #define POSIX_SPAWN_SETSIGDEF		0x10
25 #define POSIX_SPAWN_SETSIGMASK		0x20
26 
27 
28 typedef struct _posix_spawnattr	*posix_spawnattr_t;
29 typedef struct _posix_spawn_file_actions	*posix_spawn_file_actions_t;
30 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 
37 extern int posix_spawn(pid_t *pid, const char *path,
38 	const posix_spawn_file_actions_t *file_actions,
39 	const posix_spawnattr_t *attrp, char *const argv[], char *const envp[]);
40 extern int posix_spawnp(pid_t *pid, const char *file,
41 	const posix_spawn_file_actions_t *file_actions,
42 	const posix_spawnattr_t *attrp, char *const argv[],
43 	char *const envp[]);
44 
45 /* file actions functions */
46 extern int posix_spawn_file_actions_init(
47 	posix_spawn_file_actions_t *file_actions);
48 extern int posix_spawn_file_actions_destroy(
49 	posix_spawn_file_actions_t *file_actions);
50 extern int posix_spawn_file_actions_addopen(
51 	posix_spawn_file_actions_t *file_actions,
52 	int fildes, const char *path, int oflag, mode_t mode);
53 extern int posix_spawn_file_actions_addclose(
54 	posix_spawn_file_actions_t *file_actions, int fildes);
55 extern int posix_spawn_file_actions_adddup2(
56 	posix_spawn_file_actions_t *file_actions, int fildes, int newfildes);
57 
58 /* spawn attribute functions */
59 extern int posix_spawnattr_destroy(posix_spawnattr_t *attr);
60 extern int posix_spawnattr_init(posix_spawnattr_t *attr);
61 extern int posix_spawnattr_getflags(const posix_spawnattr_t *attr,
62 	short *_flags);
63 extern int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags);
64 extern int posix_spawnattr_getpgroup(const posix_spawnattr_t *attr,
65 	pid_t *_pgroup);
66 extern int posix_spawnattr_setpgroup(posix_spawnattr_t *attr, pid_t pgroup);
67 extern int posix_spawnattr_getsigdefault(const posix_spawnattr_t *attr,
68 	sigset_t *sigdefault);
69 extern int posix_spawnattr_setsigdefault(posix_spawnattr_t *attr,
70 	const sigset_t *sigdefault);
71 extern int posix_spawnattr_getsigmask(const posix_spawnattr_t *attr,
72 	sigset_t *_sigmask);
73 extern int posix_spawnattr_setsigmask(posix_spawnattr_t *attr,
74 	const sigset_t *sigmask);
75 
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 
82 #endif	/* _SPAWN_H_ */
83 
84