spawn.h revision 330897
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: stable/11/include/spawn.h 330897 2018-03-14 03:19:51Z eadler $
29 */
30
31#ifndef _SPAWN_H_
32#define _SPAWN_H_
33
34#include <sys/cdefs.h>
35#include <sys/_types.h>
36#include <sys/_sigset.h>
37
38#ifndef _MODE_T_DECLARED
39typedef	__mode_t	mode_t;
40#define	_MODE_T_DECLARED
41#endif
42
43#ifndef _PID_T_DECLARED
44typedef	__pid_t		pid_t;
45#define	_PID_T_DECLARED
46#endif
47
48#ifndef _SIGSET_T_DECLARED
49#define	_SIGSET_T_DECLARED
50typedef	__sigset_t	sigset_t;
51#endif
52
53struct sched_param;
54
55typedef struct __posix_spawnattr		*posix_spawnattr_t;
56typedef struct __posix_spawn_file_actions	*posix_spawn_file_actions_t;
57
58#define POSIX_SPAWN_RESETIDS		0x01
59#define POSIX_SPAWN_SETPGROUP		0x02
60#define POSIX_SPAWN_SETSCHEDPARAM	0x04
61#define POSIX_SPAWN_SETSCHEDULER	0x08
62#define POSIX_SPAWN_SETSIGDEF		0x10
63#define POSIX_SPAWN_SETSIGMASK		0x20
64
65__BEGIN_DECLS
66/*
67 * Spawn routines
68 *
69 * XXX both arrays should be __restrict, but this does not work when GCC
70 * is invoked with -std=c99.
71 */
72int posix_spawn(pid_t * __restrict, const char * __restrict,
73    const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict,
74    char * const [], char * const []);
75int posix_spawnp(pid_t * __restrict, const char * __restrict,
76    const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict,
77    char * const [], char * const []);
78
79/*
80 * File descriptor actions
81 */
82int posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
83int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
84
85int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict,
86    int, const char * __restrict, int, mode_t);
87int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
88int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
89
90/*
91 * Spawn attributes
92 */
93int posix_spawnattr_init(posix_spawnattr_t *);
94int posix_spawnattr_destroy(posix_spawnattr_t *);
95
96int posix_spawnattr_getflags(const posix_spawnattr_t * __restrict,
97    short * __restrict);
98int posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict,
99    pid_t * __restrict);
100int posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict,
101    struct sched_param * __restrict);
102int posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict,
103    int * __restrict);
104int posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict,
105    sigset_t * __restrict);
106int posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict,
107    sigset_t * __restrict sigmask);
108
109int posix_spawnattr_setflags(posix_spawnattr_t *, short);
110int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
111int posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict,
112    const struct sched_param * __restrict);
113int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
114int posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict,
115    const sigset_t * __restrict);
116int posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict,
117    const sigset_t * __restrict);
118__END_DECLS
119
120#endif /* !_SPAWN_H_ */
121