spawn.h revision 179873
138774Snsouch/*- 293023Snsouch * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> 338774Snsouch * All rights reserved. 438774Snsouch * 538774Snsouch * Redistribution and use in source and binary forms, with or without 638774Snsouch * modification, are permitted provided that the following conditions 738774Snsouch * are met: 838774Snsouch * 1. Redistributions of source code must retain the above copyright 938774Snsouch * notice, this list of conditions and the following disclaimer. 1038774Snsouch * 2. Redistributions in binary form must reproduce the above copyright 1138774Snsouch * notice, this list of conditions and the following disclaimer in the 1238774Snsouch * documentation and/or other materials provided with the distribution. 1338774Snsouch * 1438774Snsouch * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1538774Snsouch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1638774Snsouch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1738774Snsouch * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1838774Snsouch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1938774Snsouch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2038774Snsouch * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2138774Snsouch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2238774Snsouch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2338774Snsouch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2438774Snsouch * SUCH DAMAGE. 2538774Snsouch * 2650477Speter * $FreeBSD: head/include/spawn.h 179873 2008-06-19 07:30:32Z ed $ 2738774Snsouch */ 2838774Snsouch 2938774Snsouch#ifndef _SPAWN_H_ 30181304Sjhb#define _SPAWN_H_ 31181304Sjhb 32181304Sjhb#include <sys/cdefs.h> 33181304Sjhb#include <sys/_types.h> 3438774Snsouch#include <sys/_sigset.h> 35129291Sjoerg 3638774Snsouch#ifndef _MODE_T_DECLARED 37181304Sjhbtypedef __mode_t mode_t; 38181304Sjhb#define _MODE_T_DECLARED 3938774Snsouch#endif 4038774Snsouch 4138774Snsouch#ifndef _PID_T_DECLARED 4238774Snsouchtypedef __pid_t pid_t; 43103588Speter#define _PID_T_DECLARED 4442442Snsouch#endif 4538774Snsouch 4638774Snsouch#ifndef _SIGSET_T_DECLARED 4738774Snsouch#define _SIGSET_T_DECLARED 4838774Snsouchtypedef __sigset_t sigset_t; 4938774Snsouch#endif 5038774Snsouch 51181304Sjhbstruct sched_param; 5293023Snsouch 5338774Snsouchtypedef struct __posix_spawnattr *posix_spawnattr_t; 5438774Snsouchtypedef struct __posix_spawn_file_actions *posix_spawn_file_actions_t; 5538774Snsouch 5638774Snsouch#define POSIX_SPAWN_RESETIDS 0x01 5793023Snsouch#define POSIX_SPAWN_SETPGROUP 0x02 58130585Sphk#define POSIX_SPAWN_SETSCHEDPARAM 0x04 59181304Sjhb#define POSIX_SPAWN_SETSCHEDULER 0x08 6038774Snsouch#define POSIX_SPAWN_SETSIGDEF 0x10 6138774Snsouch#define POSIX_SPAWN_SETSIGMASK 0x20 62181304Sjhb 63181304Sjhb__BEGIN_DECLS 6438774Snsouch/* 6538774Snsouch * Spawn routines 6638774Snsouch * 6793023Snsouch * XXX both arrays should be __restrict, but this does not work when GCC 6893023Snsouch * is invoked with -std=c99. 6938774Snsouch */ 7038774Snsouchint posix_spawn(pid_t * __restrict, const char * __restrict, 7138774Snsouch const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict, 7238774Snsouch char * const [], char * const []); 7338774Snsouchint posix_spawnp(pid_t * __restrict, const char * __restrict, 7493023Snsouch const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict, 7538774Snsouch char * const [], char * const []); 7638774Snsouch 7793023Snsouch/* 7838774Snsouch * File descriptor actions 7938774Snsouch */ 8038774Snsouchint posix_spawn_file_actions_init(posix_spawn_file_actions_t *); 8138774Snsouchint posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *); 8238774Snsouch 8338774Snsouchint posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict, 8438774Snsouch int, const char * __restrict, int, mode_t); 8538774Snsouchint posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int); 8638774Snsouchint posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int); 8738774Snsouch 8838774Snsouch/* 8938774Snsouch * Spawn attributes 9038774Snsouch */ 9138774Snsouchint posix_spawnattr_init(posix_spawnattr_t *); 9238774Snsouchint posix_spawnattr_destroy(posix_spawnattr_t *); 9338774Snsouch 9438774Snsouchint posix_spawnattr_getflags(const posix_spawnattr_t * __restrict, 9538774Snsouch short * __restrict); 9638774Snsouchint posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict, 9747625Sphk pid_t * __restrict); 98126080Sphkint posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict, 99181304Sjhb struct sched_param * __restrict); 100111815Sphkint posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict, 101111815Sphk int * __restrict); 102111815Sphkint posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict, 103111815Sphk sigset_t * __restrict); 104111815Sphkint posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict, 105111815Sphk sigset_t * __restrict sigmask); 10647625Sphk 10738774Snsouchint posix_spawnattr_setflags(posix_spawnattr_t *, short); 10893023Snsouchint posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t); 10993023Snsouchint posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict, 11093023Snsouch const struct sched_param * __restrict); 111181304Sjhbint posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int); 112181304Sjhbint posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict, 113187321Snwhitehorn const sigset_t * __restrict); 11493023Snsouchint posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict, 11593023Snsouch const sigset_t * __restrict); 11638774Snsouch__END_DECLS 11738774Snsouch 11838774Snsouch#endif /* !_SPAWN_H_ */ 119187321Snwhitehorn