spawn.h revision af615399
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#define POSIX_SPAWN_SETSID			0x40
27
28
29typedef struct _posix_spawnattr	*posix_spawnattr_t;
30typedef struct _posix_spawn_file_actions	*posix_spawn_file_actions_t;
31
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37
38extern int posix_spawn(pid_t *pid, const char *path,
39	const posix_spawn_file_actions_t *file_actions,
40	const posix_spawnattr_t *attrp, char *const argv[], char *const envp[]);
41extern int posix_spawnp(pid_t *pid, const char *file,
42	const posix_spawn_file_actions_t *file_actions,
43	const posix_spawnattr_t *attrp, char *const argv[],
44	char *const envp[]);
45
46/* file actions functions */
47extern int posix_spawn_file_actions_init(
48	posix_spawn_file_actions_t *file_actions);
49extern int posix_spawn_file_actions_destroy(
50	posix_spawn_file_actions_t *file_actions);
51extern int posix_spawn_file_actions_addopen(
52	posix_spawn_file_actions_t *file_actions,
53	int fildes, const char *path, int oflag, mode_t mode);
54extern int posix_spawn_file_actions_addclose(
55	posix_spawn_file_actions_t *file_actions, int fildes);
56extern int posix_spawn_file_actions_adddup2(
57	posix_spawn_file_actions_t *file_actions, int fildes, int newfildes);
58
59/* spawn attribute functions */
60extern int posix_spawnattr_destroy(posix_spawnattr_t *attr);
61extern int posix_spawnattr_init(posix_spawnattr_t *attr);
62extern int posix_spawnattr_getflags(const posix_spawnattr_t *attr,
63	short *_flags);
64extern int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags);
65extern int posix_spawnattr_getpgroup(const posix_spawnattr_t *attr,
66	pid_t *_pgroup);
67extern int posix_spawnattr_setpgroup(posix_spawnattr_t *attr, pid_t pgroup);
68extern int posix_spawnattr_getsigdefault(const posix_spawnattr_t *attr,
69	sigset_t *sigdefault);
70extern int posix_spawnattr_setsigdefault(posix_spawnattr_t *attr,
71	const sigset_t *sigdefault);
72extern int posix_spawnattr_getsigmask(const posix_spawnattr_t *attr,
73	sigset_t *_sigmask);
74extern int posix_spawnattr_setsigmask(posix_spawnattr_t *attr,
75	const sigset_t *sigmask);
76
77
78#ifdef __cplusplus
79}
80#endif
81
82
83#endif	/* _SPAWN_H_ */
84
85