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: releng/10.2/include/spawn.h 179873 2008-06-19 07:30:32Z 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 66179873Sed * 67179873Sed * XXX both arrays should be __restrict, but this does not work when GCC 68179873Sed * is invoked with -std=c99. 69179838Sdavidxu */ 70179838Sdavidxuint posix_spawn(pid_t * __restrict, const char * __restrict, 71179838Sdavidxu const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict, 72179873Sed char * const [], char * const []); 73179838Sdavidxuint posix_spawnp(pid_t * __restrict, const char * __restrict, 74179838Sdavidxu const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict, 75179873Sed char * const [], char * const []); 76179838Sdavidxu 77179838Sdavidxu/* 78179838Sdavidxu * File descriptor actions 79179838Sdavidxu */ 80179838Sdavidxuint posix_spawn_file_actions_init(posix_spawn_file_actions_t *); 81179838Sdavidxuint posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *); 82179838Sdavidxu 83179838Sdavidxuint posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict, 84179838Sdavidxu int, const char * __restrict, int, mode_t); 85179838Sdavidxuint posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int); 86179838Sdavidxuint posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int); 87179838Sdavidxu 88179838Sdavidxu/* 89179838Sdavidxu * Spawn attributes 90179838Sdavidxu */ 91179838Sdavidxuint posix_spawnattr_init(posix_spawnattr_t *); 92179838Sdavidxuint posix_spawnattr_destroy(posix_spawnattr_t *); 93179838Sdavidxu 94179838Sdavidxuint posix_spawnattr_getflags(const posix_spawnattr_t * __restrict, 95179838Sdavidxu short * __restrict); 96179838Sdavidxuint posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict, 97179838Sdavidxu pid_t * __restrict); 98179838Sdavidxuint posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict, 99179838Sdavidxu struct sched_param * __restrict); 100179838Sdavidxuint posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict, 101179838Sdavidxu int * __restrict); 102179838Sdavidxuint posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict, 103179838Sdavidxu sigset_t * __restrict); 104179838Sdavidxuint posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict, 105179838Sdavidxu sigset_t * __restrict sigmask); 106179838Sdavidxu 107179838Sdavidxuint posix_spawnattr_setflags(posix_spawnattr_t *, short); 108179838Sdavidxuint posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t); 109179838Sdavidxuint posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict, 110179838Sdavidxu const struct sched_param * __restrict); 111179838Sdavidxuint posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int); 112179838Sdavidxuint posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict, 113179838Sdavidxu const sigset_t * __restrict); 114179838Sdavidxuint posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict, 115179838Sdavidxu const sigset_t * __restrict); 116179838Sdavidxu__END_DECLS 117179838Sdavidxu 118179838Sdavidxu#endif /* !_SPAWN_H_ */ 119