xref: /openbsd/include/spawn.h (revision b5c8b44b)
1*b5c8b44bSmillert /*	$OpenBSD: spawn.h,v 1.3 2015/05/20 22:50:07 millert Exp $	*/
25365c52eSmatthew /*-
35365c52eSmatthew  * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
45365c52eSmatthew  * All rights reserved.
55365c52eSmatthew  *
65365c52eSmatthew  * Redistribution and use in source and binary forms, with or without
75365c52eSmatthew  * modification, are permitted provided that the following conditions
85365c52eSmatthew  * are met:
95365c52eSmatthew  * 1. Redistributions of source code must retain the above copyright
105365c52eSmatthew  *    notice, this list of conditions and the following disclaimer.
115365c52eSmatthew  * 2. Redistributions in binary form must reproduce the above copyright
125365c52eSmatthew  *    notice, this list of conditions and the following disclaimer in the
135365c52eSmatthew  *    documentation and/or other materials provided with the distribution.
145365c52eSmatthew  *
155365c52eSmatthew  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
165365c52eSmatthew  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
175365c52eSmatthew  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
185365c52eSmatthew  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
195365c52eSmatthew  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
205365c52eSmatthew  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
215365c52eSmatthew  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
225365c52eSmatthew  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
235365c52eSmatthew  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
245365c52eSmatthew  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
255365c52eSmatthew  * SUCH DAMAGE.
265365c52eSmatthew  *
275365c52eSmatthew  * $FreeBSD: src/include/spawn.h,v 1.3.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $
285365c52eSmatthew  */
295365c52eSmatthew 
305365c52eSmatthew #ifndef _SPAWN_H_
315365c52eSmatthew #define _SPAWN_H_
325365c52eSmatthew 
335365c52eSmatthew #include <sys/types.h>
345365c52eSmatthew #include <sys/signal.h>
355365c52eSmatthew 
365365c52eSmatthew struct sched_param;
375365c52eSmatthew 
385365c52eSmatthew typedef struct __posix_spawnattr		*posix_spawnattr_t;
395365c52eSmatthew typedef struct __posix_spawn_file_actions	*posix_spawn_file_actions_t;
405365c52eSmatthew 
415365c52eSmatthew #define POSIX_SPAWN_RESETIDS		0x01
425365c52eSmatthew #define POSIX_SPAWN_SETPGROUP		0x02
435365c52eSmatthew #define POSIX_SPAWN_SETSCHEDPARAM	0x04
445365c52eSmatthew #define POSIX_SPAWN_SETSCHEDULER	0x08
455365c52eSmatthew #define POSIX_SPAWN_SETSIGDEF		0x10
465365c52eSmatthew #define POSIX_SPAWN_SETSIGMASK		0x20
475365c52eSmatthew 
485365c52eSmatthew __BEGIN_DECLS
495365c52eSmatthew /*
505365c52eSmatthew  * Spawn routines
515365c52eSmatthew  *
525365c52eSmatthew  * XXX both arrays should be __restrict, but this does not work when GCC
535365c52eSmatthew  * is invoked with -std=c99.
545365c52eSmatthew  */
555365c52eSmatthew int posix_spawn(pid_t *__restrict, const char *__restrict,
565365c52eSmatthew     const posix_spawn_file_actions_t *, const posix_spawnattr_t *__restrict,
575365c52eSmatthew     char *const [], char *const []);
585365c52eSmatthew int posix_spawnp(pid_t *__restrict, const char *__restrict,
595365c52eSmatthew     const posix_spawn_file_actions_t *, const posix_spawnattr_t *__restrict,
605365c52eSmatthew     char *const [], char *const []);
615365c52eSmatthew 
625365c52eSmatthew /*
635365c52eSmatthew  * File descriptor actions
645365c52eSmatthew  */
655365c52eSmatthew int posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
665365c52eSmatthew int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
675365c52eSmatthew 
685365c52eSmatthew int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict,
695365c52eSmatthew     int, const char *__restrict, int, mode_t);
705365c52eSmatthew int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
715365c52eSmatthew int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
725365c52eSmatthew 
735365c52eSmatthew /*
745365c52eSmatthew  * Spawn attributes
755365c52eSmatthew  */
765365c52eSmatthew int posix_spawnattr_init(posix_spawnattr_t *);
775365c52eSmatthew int posix_spawnattr_destroy(posix_spawnattr_t *);
785365c52eSmatthew 
795365c52eSmatthew int posix_spawnattr_getflags(const posix_spawnattr_t *__restrict,
805365c52eSmatthew     short *__restrict);
815365c52eSmatthew int posix_spawnattr_getpgroup(const posix_spawnattr_t *__restrict,
825365c52eSmatthew     pid_t *__restrict);
835365c52eSmatthew int posix_spawnattr_getschedparam(const posix_spawnattr_t *__restrict,
845365c52eSmatthew     struct sched_param *__restrict);
855365c52eSmatthew int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *__restrict,
865365c52eSmatthew     int *__restrict);
875365c52eSmatthew int posix_spawnattr_getsigdefault(const posix_spawnattr_t *__restrict,
885365c52eSmatthew     sigset_t *__restrict);
895365c52eSmatthew int posix_spawnattr_getsigmask(const posix_spawnattr_t *__restrict,
90*b5c8b44bSmillert     sigset_t *__restrict);
915365c52eSmatthew 
925365c52eSmatthew int posix_spawnattr_setflags(posix_spawnattr_t *, short);
935365c52eSmatthew int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
945365c52eSmatthew int posix_spawnattr_setschedparam(posix_spawnattr_t *__restrict,
955365c52eSmatthew     const struct sched_param *__restrict);
965365c52eSmatthew int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
975365c52eSmatthew int posix_spawnattr_setsigdefault(posix_spawnattr_t *__restrict,
985365c52eSmatthew     const sigset_t *__restrict);
995365c52eSmatthew int posix_spawnattr_setsigmask(posix_spawnattr_t *__restrict,
1005365c52eSmatthew     const sigset_t *__restrict);
1015365c52eSmatthew __END_DECLS
1025365c52eSmatthew 
1035365c52eSmatthew #endif /* !_SPAWN_H_ */
104