spawn.h revision 179840
1179838Sdavidxu/*-
2179840Sed * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
3179838Sdavidxu * All rights reserved.
4179838Sdavidxu *
5179838Sdavidxu * Redistribution and use in source and binary forms, with or without
6179838Sdavidxu * modification, are permitted provided that the following conditions
7179838Sdavidxu * are met:
8179838Sdavidxu * 1. Redistributions of source code must retain the above copyright
9179838Sdavidxu *    notice, this list of conditions and the following disclaimer.
10179838Sdavidxu * 2. Redistributions in binary form must reproduce the above copyright
11179838Sdavidxu *    notice, this list of conditions and the following disclaimer in the
12179838Sdavidxu *    documentation and/or other materials provided with the distribution.
13179838Sdavidxu *
14179838Sdavidxu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15179838Sdavidxu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16179838Sdavidxu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17179838Sdavidxu * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18179838Sdavidxu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19179838Sdavidxu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20179838Sdavidxu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21179838Sdavidxu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22179838Sdavidxu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23179838Sdavidxu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24179838Sdavidxu * SUCH DAMAGE.
25179838Sdavidxu *
26179838Sdavidxu * $FreeBSD: head/include/spawn.h 179840 2008-06-17 07:09:58Z ed $
27179838Sdavidxu */
28179838Sdavidxu
29179838Sdavidxu#ifndef _SPAWN_H_
30179838Sdavidxu#define _SPAWN_H_
31179838Sdavidxu
32179838Sdavidxu#include <sys/cdefs.h>
33179838Sdavidxu#include <sys/_types.h>
34179838Sdavidxu#include <sys/_sigset.h>
35179838Sdavidxu
36179838Sdavidxu#ifndef _MODE_T_DECLARED
37179838Sdavidxutypedef	__mode_t	mode_t;
38179838Sdavidxu#define	_MODE_T_DECLARED
39179838Sdavidxu#endif
40179838Sdavidxu
41179838Sdavidxu#ifndef _PID_T_DECLARED
42179838Sdavidxutypedef	__pid_t		pid_t;
43179838Sdavidxu#define	_PID_T_DECLARED
44179838Sdavidxu#endif
45179838Sdavidxu
46179838Sdavidxu#ifndef _SIGSET_T_DECLARED
47179838Sdavidxu#define	_SIGSET_T_DECLARED
48179838Sdavidxutypedef	__sigset_t	sigset_t;
49179838Sdavidxu#endif
50179838Sdavidxu
51179838Sdavidxustruct sched_param;
52179838Sdavidxu
53179838Sdavidxutypedef struct __posix_spawnattr		*posix_spawnattr_t;
54179838Sdavidxutypedef struct __posix_spawn_file_actions	*posix_spawn_file_actions_t;
55179838Sdavidxu
56179838Sdavidxu#define POSIX_SPAWN_RESETIDS		0x01
57179838Sdavidxu#define POSIX_SPAWN_SETPGROUP		0x02
58179838Sdavidxu#define POSIX_SPAWN_SETSCHEDPARAM	0x04
59179838Sdavidxu#define POSIX_SPAWN_SETSCHEDULER	0x08
60179838Sdavidxu#define POSIX_SPAWN_SETSIGDEF		0x10
61179838Sdavidxu#define POSIX_SPAWN_SETSIGMASK		0x20
62179838Sdavidxu
63179838Sdavidxu__BEGIN_DECLS
64179838Sdavidxu/*
65179838Sdavidxu * Spawn routines
66179838Sdavidxu */
67179838Sdavidxuint posix_spawn(pid_t * __restrict, const char * __restrict,
68179838Sdavidxu    const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict,
69179838Sdavidxu    char * const [__restrict], char * const [__restrict]);
70179838Sdavidxuint posix_spawnp(pid_t * __restrict, const char * __restrict,
71179838Sdavidxu    const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict,
72179838Sdavidxu    char * const [__restrict], char * const [__restrict]);
73179838Sdavidxu
74179838Sdavidxu/*
75179838Sdavidxu * File descriptor actions
76179838Sdavidxu */
77179838Sdavidxuint posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
78179838Sdavidxuint posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
79179838Sdavidxu
80179838Sdavidxuint posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict,
81179838Sdavidxu    int, const char * __restrict, int, mode_t);
82179838Sdavidxuint posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
83179838Sdavidxuint posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
84179838Sdavidxu
85179838Sdavidxu/*
86179838Sdavidxu * Spawn attributes
87179838Sdavidxu */
88179838Sdavidxuint posix_spawnattr_init(posix_spawnattr_t *);
89179838Sdavidxuint posix_spawnattr_destroy(posix_spawnattr_t *);
90179838Sdavidxu
91179838Sdavidxuint posix_spawnattr_getflags(const posix_spawnattr_t * __restrict,
92179838Sdavidxu    short * __restrict);
93179838Sdavidxuint posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict,
94179838Sdavidxu    pid_t * __restrict);
95179838Sdavidxuint posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict,
96179838Sdavidxu    struct sched_param * __restrict);
97179838Sdavidxuint posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict,
98179838Sdavidxu    int * __restrict);
99179838Sdavidxuint posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict,
100179838Sdavidxu    sigset_t * __restrict);
101179838Sdavidxuint posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict,
102179838Sdavidxu    sigset_t * __restrict sigmask);
103179838Sdavidxu
104179838Sdavidxuint posix_spawnattr_setflags(posix_spawnattr_t *, short);
105179838Sdavidxuint posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
106179838Sdavidxuint posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict,
107179838Sdavidxu    const struct sched_param * __restrict);
108179838Sdavidxuint posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
109179838Sdavidxuint posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict,
110179838Sdavidxu    const sigset_t * __restrict);
111179838Sdavidxuint posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict,
112179838Sdavidxu    const sigset_t * __restrict);
113179838Sdavidxu__END_DECLS
114179838Sdavidxu
115179838Sdavidxu#endif /* !_SPAWN_H_ */
116