From c4dd129bff0d01b2410934902463ac3f4293f711 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Sun, 15 Feb 2009 15:46:03 -0500 Subject: [PATCH] Add posix_spawn() and posix_spawnp(). Also add execvP() which takes the search path as an argument. Obtained-from: FreeBSD --- include/Makefile | 3 +- include/spawn.h | 122 +++++ lib/libc/gen/Makefile.inc | 22 +- lib/libc/gen/exec.3 | 53 +- lib/libc/gen/exec.c | 57 ++- lib/libc/gen/posix_spawn.3 | 455 +++++++++++++++++ lib/libc/gen/posix_spawn.c | 473 ++++++++++++++++++ .../gen/posix_spawn_file_actions_addopen.3 | 182 +++++++ lib/libc/gen/posix_spawn_file_actions_init.3 | 104 ++++ lib/libc/gen/posix_spawnattr_getflags.3 | 111 ++++ lib/libc/gen/posix_spawnattr_getpgroup.3 | 96 ++++ lib/libc/gen/posix_spawnattr_getschedparam.3 | 100 ++++ lib/libc/gen/posix_spawnattr_getschedpolicy.3 | 98 ++++ lib/libc/gen/posix_spawnattr_getsigdefault.3 | 98 ++++ lib/libc/gen/posix_spawnattr_getsigmask.3 | 98 ++++ lib/libc/gen/posix_spawnattr_init.3 | 123 +++++ lib/libc/include/libc_private.h | 3 + 17 files changed, 2156 insertions(+), 42 deletions(-) create mode 100644 include/spawn.h create mode 100644 lib/libc/gen/posix_spawn.3 create mode 100644 lib/libc/gen/posix_spawn.c create mode 100644 lib/libc/gen/posix_spawn_file_actions_addopen.3 create mode 100644 lib/libc/gen/posix_spawn_file_actions_init.3 create mode 100644 lib/libc/gen/posix_spawnattr_getflags.3 create mode 100644 lib/libc/gen/posix_spawnattr_getpgroup.3 create mode 100644 lib/libc/gen/posix_spawnattr_getschedparam.3 create mode 100644 lib/libc/gen/posix_spawnattr_getschedpolicy.3 create mode 100644 lib/libc/gen/posix_spawnattr_getsigdefault.3 create mode 100644 lib/libc/gen/posix_spawnattr_getsigmask.3 create mode 100644 lib/libc/gen/posix_spawnattr_init.3 diff --git a/include/Makefile b/include/Makefile index bbc061b80f..231c074668 100644 --- a/include/Makefile +++ b/include/Makefile @@ -21,7 +21,8 @@ INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h ctype.h db.h \ ranlib.h readpassphrase.h regex.h regexp.h \ res_update.h resolv.h re_comp.h rmd160.h \ search.h setjmp.h sgtty.h \ - signal.h stab.h stdarg.h stdbool.h stddef.h stdint.h stdio.h stdlib.h \ + signal.h spawn.h stab.h stdarg.h stdbool.h \ + stddef.h stdint.h stdio.h stdlib.h \ string.h stringlist.h strings.h struct.h sysexits.h tar.h time.h \ timeconv.h \ timers.h ttyent.h unistd.h ulimit.h utime.h utmp.h uuid.h vis.h \ diff --git a/include/spawn.h b/include/spawn.h new file mode 100644 index 0000000000..0911695a04 --- /dev/null +++ b/include/spawn.h @@ -0,0 +1,122 @@ +/*- + * Copyright (c) 2008 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/include/spawn.h,v 1.3 2008/06/19 07:30:32 ed Exp $ + */ + +#ifndef _SPAWN_H_ +#define _SPAWN_H_ + +#include +#include +#include + +#if 0 +#ifndef _MODE_T_DECLARED +typedef __mode_t mode_t; +#define _MODE_T_DECLARED +#endif + +#ifndef _PID_T_DECLARED +typedef __pid_t pid_t; +#define _PID_T_DECLARED +#endif + +#ifndef _SIGSET_T_DECLARED +#define _SIGSET_T_DECLARED +typedef __sigset_t sigset_t; +#endif +#endif + +struct sched_param; + +typedef struct __posix_spawnattr *posix_spawnattr_t; +typedef struct __posix_spawn_file_actions *posix_spawn_file_actions_t; + +#define POSIX_SPAWN_RESETIDS 0x01 +#define POSIX_SPAWN_SETPGROUP 0x02 +#define POSIX_SPAWN_SETSCHEDPARAM 0x04 +#define POSIX_SPAWN_SETSCHEDULER 0x08 +#define POSIX_SPAWN_SETSIGDEF 0x10 +#define POSIX_SPAWN_SETSIGMASK 0x20 + +__BEGIN_DECLS +/* + * Spawn routines + * + * XXX both arrays should be __restrict, but this does not work when GCC + * is invoked with -std=c99. + */ +int posix_spawn(pid_t * __restrict, const char * __restrict, + const posix_spawn_file_actions_t *, + const posix_spawnattr_t * __restrict, char * const [], + char * const []); +int posix_spawnp(pid_t * __restrict, const char * __restrict, + const posix_spawn_file_actions_t *, + const posix_spawnattr_t * __restrict, char * const [], + char * const []); + +/* + * File descriptor actions + */ +int posix_spawn_file_actions_init(posix_spawn_file_actions_t *); +int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *); + +int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict, + int, const char * __restrict, int, mode_t); +int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int); +int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int); + +/* + * Spawn attributes + */ +int posix_spawnattr_init(posix_spawnattr_t *); +int posix_spawnattr_destroy(posix_spawnattr_t *); + +int posix_spawnattr_getflags(const posix_spawnattr_t * __restrict, + short * __restrict); +int posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict, + pid_t * __restrict); +int posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict, + struct sched_param * __restrict); +int posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict, + int * __restrict); +int posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict, + sigset_t * __restrict); +int posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict, + sigset_t * __restrict sigmask); + +int posix_spawnattr_setflags(posix_spawnattr_t *, short); +int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t); +int posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict, + const struct sched_param * __restrict); +int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int); +int posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict, + const sigset_t * __restrict); +int posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict, + const sigset_t * __restrict); +__END_DECLS + +#endif /* !_SPAWN_H_ */ diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index ed272f55fd..34c6c54bbe 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -23,7 +23,7 @@ SRCS+= _pthread_stubs.c _rand48.c _spinlock_stub.c _thread_init.c \ lockf.c lrand48.c mrand48.c msgctl.c \ msgget.c msgrcv.c msgsnd.c nftw.c nice.c \ nlist.c nrand48.c ntp_gettime.c opendir.c \ - pause.c pmadvise.c popen.c posixshm.c \ + pause.c pmadvise.c popen.c posix_spawn.c posixshm.c \ psignal.c pthread_fake.c pw_scan.c pwcache.c \ raise.c readdir.c readpassphrase.c rewinddir.c \ scandir.c seed48.c seekdir.c semconfig.c semctl.c semget.c semop.c \ @@ -67,7 +67,12 @@ MAN+= alarm.3 arc4random.3 clock.3 \ iscntrl.3 isdigit.3 isgraph.3 islower.3 isprint.3 ispunct.3 \ isspace.3 isupper.3 isxdigit.3 isinf.3 isfinite.3 isnan.3 isnormal.3 \ ldexp.3 lockf.3 makecontext.3 modf.3 msgctl.3 msgget.3 msgrcv.3 msgsnd.3 \ - nice.3 nlist.3 pause.3 popen.3 psignal.3 pwcache.3 \ + nice.3 nlist.3 pause.3 popen.3 posix_spawn.3 \ + posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_init.3 \ + posix_spawnattr_getflags.3 posix_spawnattr_getpgroup.3 \ + posix_spawnattr_getschedparam.3 posix_spawnattr_getschedpolicy.3 \ + posix_spawnattr_getsigdefault.3 posix_spawnattr_getsigmask.3 \ + posix_spawnattr_init.3 psignal.3 pwcache.3 \ raise.3 rand48.3 readpassphrase.3 rfork_thread.3 \ scandir.3 setjmp.3 setmode.3 setproctitle.3 shm_open.3 \ siginterrupt.3 signal.3 signbit.3 sigsetops.3 sleep.3 stringlist.3 \ @@ -89,7 +94,7 @@ MLINKS+=err.3 err_set_exit.3 err.3 err_set_file.3 err.3 errc.3 err.3 errx.3 \ err.3 verr.3 err.3 verrc.3 err.3 verrx.3 err.3 vwarn.3 err.3 vwarnc.3 \ err.3 vwarnx.3 err.3 warnc.3 err.3 warn.3 err.3 warnx.3 MLINKS+=exec.3 execl.3 exec.3 execle.3 exec.3 execlp.3 exec.3 exect.3 \ - exec.3 execv.3 exec.3 execvp.3 + exec.3 execv.3 exec.3 execvP.3 exec.3 execvp.3 MLINKS+=fts.3 fts_children.3 fts.3 fts_close.3 fts.3 fts_open.3 \ fts.3 fts_read.3 fts.3 fts_set.3 MLINKS+=ftw.3 nftw.3 @@ -123,6 +128,17 @@ MLINKS+=glob.3 globfree.3 MLINKS+=getcontext.3 setcontext.3 MLINKS+=makecontext.3 swapcontext.3 MLINKS+=popen.3 pclose.3 +MLINKS+=posix_spawn.3 posix_spawnp.3 +MLINKS+=posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_addclose.3 \ + posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_adddup2.3 +MLINKS+=posix_spawn_file_actions_init.3 posix_spawn_file_actions_destroy.3 +MLINKS+=posix_spawnattr_getflags.3 posix_spawnattr_setflags.3 +MLINKS+=posix_spawnattr_getpgroup.3 posix_spawnattr_setpgroup.3 +MLINKS+=posix_spawnattr_getschedparam.3 posix_spawnattr_setschedparam.3 +MLINKS+=posix_spawnattr_getschedpolicy.3 posix_spawnattr_setschedpolicy.3 +MLINKS+=posix_spawnattr_getsigdefault.3 posix_spawnattr_setsigdefault.3 +MLINKS+=posix_spawnattr_getsigmask.3 posix_spawnattr_setsigmask.3 +MLINKS+=posix_spawnattr_init.3 posix_spawnattr_destroy.3 MLINKS+=psignal.3 strsignal.3 psignal.3 sys_nsig.3 psignal.3 sys_siglist.3 \ psignal.3 sys_signame.3 MLINKS+=pwcache.3 group_from_gid.3 pwcache.3 user_from_uid.3 diff --git a/lib/libc/gen/exec.3 b/lib/libc/gen/exec.3 index 2af717f589..9e995683fb 100644 --- a/lib/libc/gen/exec.3 +++ b/lib/libc/gen/exec.3 @@ -9,10 +9,6 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. @@ -30,7 +26,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)exec.3 8.3 (Berkeley) 1/24/94 -.\" $FreeBSD: src/lib/libc/gen/exec.3,v 1.7.2.8 2003/03/15 15:11:05 trhodes Exp $ +.\" $FreeBSD: src/lib/libc/gen/exec.3,v 1.28 2008/06/23 05:22:06 ed Exp $ .\" $DragonFly: src/lib/libc/gen/exec.3,v 1.5 2007/12/21 22:14:04 swildner Exp $ .\" .Dd December 21, 2007 @@ -42,7 +38,8 @@ .Nm execle , .Nm exect , .Nm execv , -.Nm execvp +.Nm execvp , +.Nm execvP .Nd execute a file .Sh LIBRARY .Lb libc @@ -50,17 +47,25 @@ .In unistd.h .Vt extern char **environ ; .Ft int -.Fn execl "const char *path" "const char *arg" ... +.Fn execl "const char *path" "const char *arg" ... /* "(char *)0" */ .Ft int -.Fn execlp "const char *file" "const char *arg" ... +.Fn execlp "const char *file" "const char *arg" ... /* "(char *)0" */ .Ft int -.Fn execle "const char *path" "const char *arg" ... +.Fo execle +.Fa "const char *path" "const char *arg" ... +.Fa /* +.Bk -words +.Fa "(char *)0" "char *const envp[]" */ +.Ek +.Fc .Ft int .Fn exect "const char *path" "char *const argv[]" "char *const envp[]" .Ft int .Fn execv "const char *path" "char *const argv[]" .Ft int .Fn execvp "const char *file" "char *const argv[]" +.Ft int +.Fn execvP "const char *file" "const char *search_path" "char *const argv[]" .Sh DESCRIPTION The .Nm exec @@ -104,8 +109,9 @@ pointer. The .Fn exect , .Fn execv , +.Fn execvp , and -.Fn execvp +.Fn execvP functions provide an array of pointers to null-terminated strings that represent the argument list available to the new program. The first argument, by convention, should point to the file name associated @@ -139,23 +145,31 @@ in the current process. Some of these functions have special semantics. .Pp The functions -.Fn execlp +.Fn execlp , +.Fn execvp , and -.Fn execvp +.Fn execvP will duplicate the actions of the shell in searching for an executable file if the specified file name does not contain a slash .Dq Li / character. -The search path is the path specified in the environment by +For +.Fn execlp +and +.Fn execvp , +search path is the path specified in the environment by .Dq Ev PATH variable. -If this variable isn't specified, +If this variable is not specified, the default path is set according to the .Dv _PATH_DEFPATH definition in .In paths.h , which is set to .Dq Ev /usr/bin:/bin . +For +.Fn execvP , +the search path is specified as an argument to the function. In addition, certain errors are treated specially. .Pp If an error is ambiguous (for simplicity, we shall consider all @@ -183,7 +197,7 @@ or according to whether at least one file with suitable execute permissions was found. .Pp -If the header of a file isn't recognized (the attempted +If the header of a file is not recognized (the attempted .Fn execve returned .Er ENOEXEC ) , @@ -267,9 +281,10 @@ The behaviour was changed to match the behaviour of The .Fn execl , .Fn execle , -.Fn execlp -and +.Fn execlp , .Fn execvp +and +.Fn execvP functions may fail and set .Va errno @@ -306,3 +321,7 @@ and functions conform to .St -p1003.1-88 . +The +.Fn execvP +function first appeared in +.Fx 5.2 . diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index ca1166e7d3..7adb486570 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -30,11 +26,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libc/gen/exec.c,v 1.15 2000/01/27 23:06:14 jasone Exp $ - * $DragonFly: src/lib/libc/gen/exec.c,v 1.7 2005/11/13 00:07:42 swildner Exp $ - * * @(#)exec.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/gen/exec.c,v 1.15 2000/01/27 23:06:14 jasone Exp $ + * $FreeBSD: src/lib/libc/gen/exec.c,v 1.25 2008/06/23 05:22:06 ed Exp $ + * $DragonFly: src/lib/libc/gen/exec.c,v 1.7 2005/11/13 00:07:42 swildner Exp $ */ #include "namespace.h" @@ -47,9 +41,10 @@ #include #include #include -#include "un-namespace.h" #include +#include "un-namespace.h" +#include "libc_private.h" extern char **environ; @@ -143,12 +138,19 @@ execv(const char *name, char * const *argv) int execvp(const char *name, char * const *argv) +{ + return (_execvpe(name, argv, environ)); +} + +static int +execvPe(const char *name, const char *path, char * const *argv, + char * const *envp) { const char **memp; int cnt; size_t lp, ln; int eacces, save_errno; - const char *bp, *p, *path; + const char *bp, *p; char *cur, buf[MAXPATHLEN]; struct stat sb; @@ -158,7 +160,6 @@ execvp(const char *name, char * const *argv) if (index(name, '/')) { bp = name; cur = NULL; - path = NULL; goto retry; } bp = buf; @@ -169,22 +170,18 @@ execvp(const char *name, char * const *argv) return (-1); } - /* Get the path we're searching. */ - if (!(path = getenv("PATH"))) - path = _PATH_DEFPATH; cur = alloca(strlen(path) + 1); if (cur == NULL) { errno = ENOMEM; return (-1); } strcpy(cur, path); - path = cur; - while ( (p = strsep(&cur, ":")) ) { + while ((p = strsep(&cur, ":")) != NULL) { /* * It's a SHELL path -- double, leading and trailing colons * mean the current directory. */ - if (!*p) { + if (*p == '\0') { p = "."; lp = 1; } else @@ -197,7 +194,7 @@ execvp(const char *name, char * const *argv) * the user may execute the wrong program. */ if (lp + ln + 2 > sizeof(buf)) { - _write(STDERR_FILENO, "execvp: ", 8); + _write(STDERR_FILENO, "execvP: ", 8); _write(STDERR_FILENO, p, lp); _write(STDERR_FILENO, ": path too long\n", 16); continue; @@ -206,9 +203,9 @@ execvp(const char *name, char * const *argv) buf[lp] = '/'; bcopy(name, buf + lp + 1, ln); buf[lp + ln + 1] = '\0'; - -retry: _execve(bp, argv, environ); - switch(errno) { +retry: + _execve(bp, argv, environ); + switch (errno) { case E2BIG: goto done; case ELOOP: @@ -263,3 +260,21 @@ retry: _execve(bp, argv, environ); done: return (-1); } + +int +execvP(const char *name, const char *path, char * const argv[]) +{ + return execvPe(name, path, argv, environ); +} + +int +_execvpe(const char *name, char * const argv[], char * const envp[]) +{ + const char *path; + + /* Get the path we're searching. */ + if ((path = getenv("PATH")) == NULL) + path = _PATH_DEFPATH; + + return (execvPe(name, path, argv, envp)); +} diff --git a/lib/libc/gen/posix_spawn.3 b/lib/libc/gen/posix_spawn.3 new file mode 100644 index 0000000000..bcbdb51224 --- /dev/null +++ b/lib/libc/gen/posix_spawn.3 @@ -0,0 +1,455 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawn.3,v 1.2 2008/07/28 09:36:56 ed Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWN 3 +.Os +.Sh NAME +.Nm posix_spawn , +.Nm posix_spawnp +.Nd "spawn a process" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawn "pid_t *restrict pid" "const char *restrict path" "const posix_spawn_file_actions_t *file_actions" "const posix_spawnattr_t *restrict attrp" "char *const argv[restrict]" "char *const envp[restrict]" +.Ft int +.Fn posix_spawnp "pid_t *restrict pid" "const char *restrict file" "const posix_spawn_file_actions_t *file_actions" "const posix_spawnattr_t *restrict attrp" "char *const argv[restrict]" "char *const envp[restrict]" +.Sh DESCRIPTION +The +.Fn posix_spawn +and +.Fn posix_spawnp +functions create a new process (child process) from the specified +process image. +The new process image is constructed from a regular executable +file called the new process image file. +.Pp +When a C program is executed as the result of this call, it is +entered as a C-language function call as follows: +.Bd -literal -offset indent +int main(int argc, char *argv[]); +.Ed +.Pp +where +.Fa argc +is the argument count and +.Fa argv +is an array of character pointers to the arguments themselves. +In addition, the variable: +.Bd -literal -offset indent +extern char **environ; +.Ed +.Pp +points to an array of character pointers to +the environment strings. +.Pp +The argument +.Fa argv +is an array of character pointers to null-terminated +strings. +The last member of this array is a null pointer and is not counted +in +.Fa argc . +These strings constitute the argument list available to the new process +image. +The value in +.Fa argv Ns [0] +should point to +a filename that is associated with the process image being started by +the +.Fn posix_spawn +or +.Fn posix_spawnp +function. +.Pp +The argument +.Fa envp +is an array of character pointers to null-terminated strings. +These strings constitute the environment for the new process image. +The environment array is terminated by a null pointer. +.Pp +The +.Fa path +argument to +.Fn posix_spawn +is a pathname that identifies the new process image file to execute. +.Pp +The +.Fa file +parameter to +.Fn posix_spawnp +is used to construct a pathname that identifies the new process +image file. +If the file parameter contains a slash character, the file parameter +is used as the pathname for the new process image file. +Otherwise, the path prefix for this file is obtained by a search +of the directories passed as the environment variable +.Dq Ev PATH . +If this variable is not specified, +the default path is set according to the +.Dv _PATH_DEFPATH +definition in +.In paths.h , +which is set to +.Dq Ev /usr/bin:/bin . +.Pp +If +.Fa file_actions +is a null pointer, then file descriptors open in the +calling process remain open in the child process, except for those +whose close-on-exec flag +.Dv FD_CLOEXEC +is set (see +.Fn fcntl ) . +For those +file descriptors that remain open, all attributes of the corresponding +open file descriptions, including file locks (see +.Fn fcntl ) , +remain unchanged. +.Pp +If +.Fa file_actions +is not NULL, then the file descriptors open in the child process are +those open in the calling process as modified by the spawn file +actions object pointed to by +.Fa file_actions +and the +.Dv FD_CLOEXEC +flag of each remaining open file descriptor after the spawn file actions +have been processed. +The effective order of processing the spawn file actions are: +.Bl -enum +.It +The set of open file descriptors for the child process initially +are the same set as is open for the calling process. +All attributes of the corresponding open file descriptions, including +file locks (see +.Fn fcntl ) , +remain unchanged. +.It +The signal mask, signal default actions, and the effective user and +group IDs for the child process are changed as specified in the +attributes object referenced by +.Fa attrp . +.It +The file actions specified by the spawn file actions object are +performed in the order in which they were added to the spawn file +actions object. +.It +Any file descriptor that has its +.Dv FD_CLOEXEC +flag set (see +.Fn fcntl ) +is closed. +.El +.Pp +The +.Vt posix_spawnattr_t +spawn attributes object type is defined in +.In spawn.h . +It contains the attributes defined below. +.Pp +If the +.Dv POSIX_SPAWN_SETPGROUP +flag is set in the spawn-flags attribute of the object referenced by +.Fa attrp , +and the spawn-pgroup attribute of the same object is non-zero, then the +child's process group is as specified in the spawn-pgroup +attribute of the object referenced by +.Fa attrp . +.Pp +As a special case, if the +.Dv POSIX_SPAWN_SETPGROUP +flag is set in the spawn-flags attribute of the object referenced by +.Fa attrp , +and the spawn-pgroup attribute of the same object is set to zero, then +the child is in a new process group with a process group ID equal +to its process ID. +.Pp +If the +.Dv POSIX_SPAWN_SETPGROUP +flag is not set in the spawn-flags attribute of the object referenced by +.Fa attrp , +the new child process inherits the parent's process group. +.Pp +If the +.Dv POSIX_SPAWN_SETSCHEDPARAM +flag is set in the spawn-flags attribute of the object referenced by +.Fa attrp , +but +.Dv POSIX_SPAWN_SETSCHEDULER +is not set, the new process image initially has the scheduling +policy of the calling process with the scheduling parameters specified +in the spawn-schedparam attribute of the object referenced by +.Fa attrp . +.Pp +If the +.Dv POSIX_SPAWN_SETSCHEDULER +flag is set in the spawn-flags attribute of the object referenced by +.Fa attrp +(regardless of the setting of the +.Dv POSIX_SPAWN_SETSCHEDPARAM +flag), the new process image initially has the scheduling policy +specified in the spawn-schedpolicy attribute of the object referenced by +.Fa attrp +and the scheduling parameters specified in the spawn-schedparam +attribute of the same object. +.Pp +The +.Dv POSIX_SPAWN_RESETIDS +flag in the spawn-flags attribute of the object referenced by +.Fa attrp +governs the effective user ID of the child process. +If this flag is not set, the child process inherits the parent +process' effective user ID. +If this flag is set, the child process' effective user ID is reset +to the parent's real user ID. +In either case, if the set-user-ID mode bit of the new process image +file is set, the effective user ID of the child process becomes +that file's owner ID before the new process image begins execution. +.Pp +The +.Dv POSIX_SPAWN_RESETIDS +flag in the spawn-flags attribute of the object referenced by +.Fa attrp +also governs the effective group ID of the child process. +If this flag is not set, the child process inherits the parent +process' effective group ID. +If this flag is set, the child process' effective group ID is +reset to the parent's real group ID. +In either case, if the set-group-ID mode bit of the new process image +file is set, the effective group ID of the child process becomes +that file's group ID before the new process image begins execution. +.Pp +If the +.Dv POSIX_SPAWN_SETSIGMASK +flag is set in the spawn-flags attribute of the object referenced by +.Fa attrp , +the child process initially has the signal mask specified in the +spawn-sigmask attribute of the object referenced by +.Fa attrp . +.Pp +If the +.Dv POSIX_SPAWN_SETSIGDEF +flag is set in the spawn-flags attribute of the object referenced by +.Fa attrp , +the signals specified in the spawn-sigdefault attribute of the same +object is set to their default actions in the child process. +Signals set to the default action in the parent process is set to +the default action in the child process. +.Pp +Signals set to be caught by the calling process is set to the +default action in the child process. +.Pp +Signals set to be ignored by the calling process image is set to +be ignored by the child process, unless otherwise specified by the +.Dv POSIX_SPAWN_SETSIGDEF +flag being set in the spawn-flags attribute of the object referenced by +.Fa attrp +and the signals being indicated in the spawn-sigdefault attribute +of the object referenced by +.Fa attrp . +.Pp +If the value of the +.Fa attrp +pointer is NULL, then the default values are used. +.Pp +All process attributes, other than those influenced by the attributes +set in the object referenced by +.Fa attrp +as specified above or by the file descriptor manipulations specified in +.Fa file_actions , +appear in the new process image as though +.Fn vfork +had been called to create a child process and then +.Fn execve +had been called by the child process to execute the new process image. +.Pp +The implementation uses vfork(), thus the fork handlers are not run when +.Fn posix_spawn +or +.Fn posix_spawnp +is called. +.Sh RETURN VALUES +Upon successful completion, +.Fn posix_spawn +and +.Fn posix_spawnp +return the process ID of the child process to the parent process, +in the variable pointed to by a non-NULL +.Fa pid +argument, and return zero as the function return value. +Otherwise, no child process is created, no value is stored into +the variable pointed to by +.Fa pid , +and an error number is returned as the function return value to +indicate the error. +If the +.Fa pid +argument is a null pointer, the process ID of the child is not returned +to the caller. +.Sh ERRORS +.Bl -enum +.It +If +.Fn posix_spawn +and +.Fn posix_spawnp +fail for any of the reasons that would cause +.Fn vfork +or one of the +.Nm exec +to fail, an error value is returned as described by +.Fn vfork +and +.Nm exec , +respectively (or, if the error occurs after the calling process successfully +returns, the child process exits with exit status 127). +.It +If +.Nm POSIX_SPAWN_SETPGROUP +is set in the spawn-flags attribute of the object referenced by attrp, and +.Fn posix_spawn +or +.Fn posix_spawnp +fails while changing the child's process group, an error value is returned as +described by +.Fn setpgid +(or, if the error occurs after the calling process successfully returns, +the child process exits with exit status 127). +.It +If +.Nm POSIX_SPAWN_SETSCHEDPARAM +is set and +.Nm POSIX_SPAWN_SETSCHEDULER +is not set in the spawn-flags attribute of the object referenced by attrp, then +if +.Fn posix_spawn +or +.Fn posix_spawnp +fails for any of the reasons that would cause +.Fn sched_setparam +to fail, an error value is returned as described by +.Fn sched_setparam +(or, if the error occurs after the calling process successfully returns, the +child process exits with exit status 127). +.It +If +.Nm POSIX_SPAWN_SETSCHEDULER +is set in the spawn-flags attribute of the object referenced by attrp, and if +.Fn posix_spawn +or +.Fn posix_spawnp +fails for any of the reasons that would cause +.Fn sched_setscheduler +to fail, an error value is returned as described by +.Fn sched_setscheduler +(or, if the error occurs after the calling process successfully returns, +the child process exits with exit status 127). +.It +If the +.Fa file_actions +argument is not NULL, and specifies any close, dup2, or open actions to be +performed, and if +.Fn posix_spawn +or +.Fn posix_spawnp +fails for any of the reasons that would cause +.Fn close , +.Fn dup2 , +or +.Fn open +to fail, an error value is returned as described by +.Fn close , +.Fn dup2 , +and +.Fn open , +respectively (or, if the error occurs after the calling process successfully +returns, the child process exits with exit status 127). An open file action +may, by itself, result in any of the errors described by +.Fn close +or +.Fn dup2 , +in addition to those described by +.Fn open . +.El +.Sh SEE ALSO +.Xr close 2 , +.Xr dup2 2 , +.Xr execve 2 , +.Xr fcntl 2 , +.Xr open 2 , +.Xr posix_spawn_file_actions_addclose 3 , +.Xr posix_spawn_file_actions_adddup2 3 , +.Xr posix_spawn_file_actions_addopen 3 , +.Xr posix_spawn_file_actions_destroy 3 , +.Xr posix_spawn_file_actions_init 3 , +.Xr posix_spawnattr_destroy 3 , +.Xr posix_spawnattr_getflags 3 , +.Xr posix_spawnattr_getpgroup 3 , +.Xr posix_spawnattr_getschedparam 3 , +.Xr posix_spawnattr_getschedpolicy 3 , +.Xr posix_spawnattr_getsigdefault 3 , +.Xr posix_spawnattr_getsigmask 3 , +.Xr posix_spawnattr_init 3 , +.Xr posix_spawnattr_setflags 3 , +.Xr posix_spawnattr_setpgroup 3 , +.Xr posix_spawnattr_setschedparam 3 , +.Xr posix_spawnattr_setschedpolicy 3 , +.Xr posix_spawnattr_setsigdefault 3 , +.Xr posix_spawnattr_setsigmask 3 , +.Xr sched_setparam 2 , +.Xr sched_setscheduler 2 , +.Xr setpgid 2 , +.Xr vfork 2 +.Sh STANDARDS +The +.Fn posix_spawn +and +.Fn posix_spawnp +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawn +and +.Fn posix_spawnp +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c new file mode 100644 index 0000000000..5dd704f798 --- /dev/null +++ b/lib/libc/gen/posix_spawn.c @@ -0,0 +1,473 @@ +/*- + * Copyright (c) 2008 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/lib/libc/gen/posix_spawn.c,v 1.6 2008/10/23 15:32:06 rdivacky Exp $ + */ + +#include "namespace.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "un-namespace.h" +#include "libc_private.h" + +extern char **environ; + +struct __posix_spawnattr { + short sa_flags; + pid_t sa_pgroup; + struct sched_param sa_schedparam; + int sa_schedpolicy; + sigset_t sa_sigdefault; + sigset_t sa_sigmask; +}; + +struct __posix_spawn_file_actions { + STAILQ_HEAD(, __posix_spawn_file_actions_entry) fa_list; +}; + +typedef struct __posix_spawn_file_actions_entry { + STAILQ_ENTRY(__posix_spawn_file_actions_entry) fae_list; + enum { FAE_OPEN, FAE_DUP2, FAE_CLOSE } fae_action; + + int fae_fildes; + union { + struct { + char *path; +#define fae_path fae_data.open.path + int oflag; +#define fae_oflag fae_data.open.oflag + mode_t mode; +#define fae_mode fae_data.open.mode + } open; + struct { + int newfildes; +#define fae_newfildes fae_data.dup2.newfildes + } dup2; + } fae_data; +} posix_spawn_file_actions_entry_t; + +/* + * Spawn routines + */ + +static int +process_spawnattr(const posix_spawnattr_t sa) +{ + struct sigaction sigact = { .sa_flags = 0, .sa_handler = SIG_DFL }; + int i; + + /* + * POSIX doesn't really describe in which order everything + * should be set. We'll just set them in the order in which they + * are mentioned. + */ + + /* Set process group */ + if (sa->sa_flags & POSIX_SPAWN_SETPGROUP) { + if (setpgid(0, sa->sa_pgroup) != 0) + return (errno); + } + + /* Set scheduler policy */ + if (sa->sa_flags & POSIX_SPAWN_SETSCHEDULER) { + if (sched_setscheduler(0, sa->sa_schedpolicy, + &sa->sa_schedparam) != 0) + return (errno); + } else if (sa->sa_flags & POSIX_SPAWN_SETSCHEDPARAM) { + if (sched_setparam(0, &sa->sa_schedparam) != 0) + return (errno); + } + + /* Reset user ID's */ + if (sa->sa_flags & POSIX_SPAWN_RESETIDS) { + if (setegid(getgid()) != 0) + return (errno); + if (seteuid(getuid()) != 0) + return (errno); + } + + /* Set signal masks/defaults */ + if (sa->sa_flags & POSIX_SPAWN_SETSIGMASK) { + _sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); + } + + if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) { + for (i = 1; i <= _SIG_MAXSIG; i++) { + if (sigismember(&sa->sa_sigdefault, i)) + if (_sigaction(i, &sigact, NULL) != 0) + return (errno); + } + } + + return (0); +} + +static int +process_file_actions_entry(posix_spawn_file_actions_entry_t *fae) +{ + int fd; + + switch (fae->fae_action) { + case FAE_OPEN: + /* Perform an open(), make it use the right fd */ + fd = _open(fae->fae_path, fae->fae_oflag, fae->fae_mode); + if (fd < 0) + return (errno); + if (fd != fae->fae_fildes) { + if (_dup2(fd, fae->fae_fildes) == -1) + return (errno); + if (_close(fd) != 0) { + if (errno == EBADF) + return (EBADF); + } + } + if (_fcntl(fae->fae_fildes, F_SETFD, 0) == -1) + return (errno); + break; + case FAE_DUP2: + /* Perform a dup2() */ + if (_dup2(fae->fae_fildes, fae->fae_newfildes) == -1) + return (errno); + if (_fcntl(fae->fae_newfildes, F_SETFD, 0) == -1) + return (errno); + break; + case FAE_CLOSE: + /* Perform a close() */ + if (_close(fae->fae_fildes) != 0) { + if (errno == EBADF) + return (EBADF); + } + break; + } + return (0); +} + +static int +process_file_actions(const posix_spawn_file_actions_t fa) +{ + posix_spawn_file_actions_entry_t *fae; + int error; + + /* Replay all file descriptor modifications */ + STAILQ_FOREACH(fae, &fa->fa_list, fae_list) { + error = process_file_actions_entry(fae); + if (error) + return (error); + } + return (0); +} + +static int +do_posix_spawn(pid_t *pid, const char *path, + const posix_spawn_file_actions_t *fa, + const posix_spawnattr_t *sa, char * const argv[], + char * const envp[], int use_env_path) +{ + pid_t p; + volatile int error = 0; + + p = vfork(); + switch (p) { + case -1: + return (errno); + case 0: + if (sa != NULL) { + error = process_spawnattr(*sa); + if (error) + _exit(127); + } + if (fa != NULL) { + error = process_file_actions(*fa); + if (error) + _exit(127); + } + if (use_env_path) + _execvpe(path, argv, envp != NULL ? envp : environ); + else + _execve(path, argv, envp != NULL ? envp : environ); + error = errno; + _exit(127); + default: + if (pid != NULL) + *pid = p; + return (error); + } +} + +int +posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa, + const posix_spawnattr_t *sa, char * const argv[], + char * const envp[]) +{ + return do_posix_spawn(pid, path, fa, sa, argv, envp, 0); +} + +int +posix_spawnp(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa, + const posix_spawnattr_t *sa, char * const argv[], + char * const envp[]) +{ + return do_posix_spawn(pid, path, fa, sa, argv, envp, 1); +} + +/* + * File descriptor actions + */ + +int +posix_spawn_file_actions_init(posix_spawn_file_actions_t *ret) +{ + posix_spawn_file_actions_t fa; + + fa = malloc(sizeof(struct __posix_spawn_file_actions)); + if (fa == NULL) + return (-1); + + STAILQ_INIT(&fa->fa_list); + *ret = fa; + return (0); +} + +int +posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *fa) +{ + posix_spawn_file_actions_entry_t *fae; + + while ((fae = STAILQ_FIRST(&(*fa)->fa_list)) != NULL) { + /* Remove file action entry from the queue */ + STAILQ_REMOVE_HEAD(&(*fa)->fa_list, fae_list); + + /* Deallocate file action entry */ + if (fae->fae_action == FAE_OPEN) + free(fae->fae_path); + free(fae); + } + + free(*fa); + return (0); +} + +int +posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict fa, + int fildes, const char * __restrict path, + int oflag, mode_t mode) +{ + posix_spawn_file_actions_entry_t *fae; + int error; + + if (fildes < 0) + return (EBADF); + + /* Allocate object */ + fae = malloc(sizeof(posix_spawn_file_actions_entry_t)); + if (fae == NULL) + return (errno); + + /* Set values and store in queue */ + fae->fae_action = FAE_OPEN; + fae->fae_path = strdup(path); + if (fae->fae_path == NULL) { + error = errno; + free(fae); + return (error); + } + fae->fae_fildes = fildes; + fae->fae_oflag = oflag; + fae->fae_mode = mode; + + STAILQ_INSERT_TAIL(&(*fa)->fa_list, fae, fae_list); + return (0); +} + +int +posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, + int fildes, int newfildes) +{ + posix_spawn_file_actions_entry_t *fae; + + if (fildes < 0 || newfildes < 0) + return (EBADF); + + /* Allocate object */ + fae = malloc(sizeof(posix_spawn_file_actions_entry_t)); + if (fae == NULL) + return (errno); + + /* Set values and store in queue */ + fae->fae_action = FAE_DUP2; + fae->fae_fildes = fildes; + fae->fae_newfildes = newfildes; + + STAILQ_INSERT_TAIL(&(*fa)->fa_list, fae, fae_list); + return (0); +} + +int +posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, + int fildes) +{ + posix_spawn_file_actions_entry_t *fae; + + if (fildes < 0) + return (EBADF); + + /* Allocate object */ + fae = malloc(sizeof(posix_spawn_file_actions_entry_t)); + if (fae == NULL) + return (errno); + + /* Set values and store in queue */ + fae->fae_action = FAE_CLOSE; + fae->fae_fildes = fildes; + + STAILQ_INSERT_TAIL(&(*fa)->fa_list, fae, fae_list); + return (0); +} + +/* + * Spawn attributes + */ + +int +posix_spawnattr_init(posix_spawnattr_t *ret) +{ + posix_spawnattr_t sa; + + sa = calloc(1, sizeof(struct __posix_spawnattr)); + if (sa == NULL) + return (errno); + + /* Set defaults as specified by POSIX, cleared above */ + *ret = sa; + return (0); +} + +int +posix_spawnattr_destroy(posix_spawnattr_t *sa) +{ + free(*sa); + return (0); +} + +int +posix_spawnattr_getflags(const posix_spawnattr_t * __restrict sa, + short * __restrict flags) +{ + *flags = (*sa)->sa_flags; + return (0); +} + +int +posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict sa, + pid_t * __restrict pgroup) +{ + *pgroup = (*sa)->sa_pgroup; + return (0); +} + +int +posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict sa, + struct sched_param * __restrict schedparam) +{ + *schedparam = (*sa)->sa_schedparam; + return (0); +} + +int +posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict sa, + int * __restrict schedpolicy) +{ + *schedpolicy = (*sa)->sa_schedpolicy; + return (0); +} + +int +posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict sa, + sigset_t * __restrict sigdefault) +{ + *sigdefault = (*sa)->sa_sigdefault; + return (0); +} + +int +posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict sa, + sigset_t * __restrict sigmask) +{ + *sigmask = (*sa)->sa_sigmask; + return (0); +} + +int +posix_spawnattr_setflags(posix_spawnattr_t *sa, short flags) +{ + (*sa)->sa_flags = flags; + return (0); +} + +int +posix_spawnattr_setpgroup(posix_spawnattr_t *sa, pid_t pgroup) +{ + (*sa)->sa_pgroup = pgroup; + return (0); +} + +int +posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict sa, + const struct sched_param * __restrict schedparam) +{ + (*sa)->sa_schedparam = *schedparam; + return (0); +} + +int +posix_spawnattr_setschedpolicy(posix_spawnattr_t *sa, int schedpolicy) +{ + (*sa)->sa_schedpolicy = schedpolicy; + return (0); +} + +int +posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict sa, + const sigset_t * __restrict sigdefault) +{ + (*sa)->sa_sigdefault = *sigdefault; + return (0); +} + +int +posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict sa, + const sigset_t * __restrict sigmask) +{ + (*sa)->sa_sigmask = *sigmask; + return (0); +} diff --git a/lib/libc/gen/posix_spawn_file_actions_addopen.3 b/lib/libc/gen/posix_spawn_file_actions_addopen.3 new file mode 100644 index 0000000000..8c3c1d5d44 --- /dev/null +++ b/lib/libc/gen/posix_spawn_file_actions_addopen.3 @@ -0,0 +1,182 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawn_file_actions_addopen.3,v 1.2 2008/07/28 09:36:56 ed Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3 +.Os +.Sh NAME +.Nm posix_spawn_file_actions_addopen , +.Nm posix_spawn_file_actions_adddup2 , +.Nm posix_spawn_file_actions_addclose +.Nd "add open, dup2 or close action to spawn file actions object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawn_file_actions_addopen "posix_spawn_file_actions_t * file_actions" "int fildes" "const char *restrict path" "int oflag" "mode_t mode" +.Ft int +.Fn posix_spawn_file_actions_adddup2 "posix_spawn_file_actions_t * file_actions" "int fildes" "int newfildes" +.Ft int +.Fn posix_spawn_file_actions_addclose "posix_spawn_file_actions_t * file_actions" "int fildes" +.Sh DESCRIPTION +These functions add an open, dup2 or close action to a spawn +file actions object. +.Pp +A spawn file actions object is of type +.Vt posix_spawn_file_actions_t +(defined in +.In spawn.h ) +and is used to specify a series of actions to be performed by a +.Fn posix_spawn +or +.Fn posix_spawnp +operation in order to arrive at the set of open file descriptors for the +child process given the set of open file descriptors of the parent. +.Pp +A spawn file actions object, when passed to +.Fn posix_spawn +or +.Fn posix_spawnp , +specify how the set of open file descriptors in the calling +process is transformed into a set of potentially open file descriptors +for the spawned process. +This transformation is as if the specified sequence of actions was +performed exactly once, in the context of the spawned process (prior to +execution of the new process image), in the order in which the actions +were added to the object; additionally, when the new process image is +executed, any file descriptor (from this new set) which has its +.Dv FD_CLOEXEC +flag set is closed (see +.Fn posix_spawn ) . +.Pp +The +.Fn posix_spawn_file_actions_addopen +function adds an open action to the object referenced by +.Fa file_actions +that causes the file named by +.Fa path +to be opened (as if +.Bd -literal -offset indent +open(path, oflag, mode) +.Ed +.Pp +had been called, and the returned file descriptor, if not +.Fa fildes , +had been changed to +.Fa fildes ) +when a new process is spawned using this file actions object. +If +.Fa fildes +was already an open file descriptor, it is closed before the new +file is opened. +.Pp +The string described by +.Fa path +is copied by the +.Fn posix_spawn_file_actions_addopen +function. +.Pp +The +.Fn posix_spawn_file_actions_adddup2 +function adds a dup2 action to the object referenced by +.Fa file_actions +that causes the file descriptor +.Fa fildes +to be duplicated as +.Fa newfildes +(as if +.Bd -literal -offset indent +dup2(fildes, newfildes) +.Ed +.Pp +had been called) when a new process is spawned using this file actions object. +.Pp +The +.Fn posix_spawn_file_actions_addclose +function adds a close action to the object referenced by +.Fa file_actions +that causes the file descriptor +.Fa fildes +to be closed (as if +.Bd -literal -offset indent +close(fildes) +.Ed +.Pp +had been called) when a new process is spawned using this file actions +object. +.Sh RETURN VALUES +Upon successful completion, these functions return zero; +otherwise, an error number is returned to indicate the error. +.Sh ERRORS +These +functions fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa fildes +or +.Fa newfildes +is negative. +.It Bq Er ENOMEM +Insufficient memory exists to add to the spawn file actions object. +.El +.Sh SEE ALSO +.Xr close 2 , +.Xr dup2 2 , +.Xr open 2 , +.Xr posix_spawn 3 , +.Xr posix_spawn_file_actions_destroy 3 , +.Xr posix_spawn_file_actions_init 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawn_file_actions_addopen , +.Fn posix_spawn_file_actions_adddup2 +and +.Fn posix_spawn_file_actions_addclose +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawn_file_actions_addopen , +.Fn posix_spawn_file_actions_adddup2 +and +.Fn posix_spawn_file_actions_addclose +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawn_file_actions_init.3 b/lib/libc/gen/posix_spawn_file_actions_init.3 new file mode 100644 index 0000000000..366f7d06ec --- /dev/null +++ b/lib/libc/gen/posix_spawn_file_actions_init.3 @@ -0,0 +1,104 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawn_file_actions_init.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWN_FILE_ACTIONS_INIT 3 +.Os +.Sh NAME +.Nm posix_spawn_file_actions_init , +.Nm posix_spawn_file_actions_destroy +.Nd "initialize and destroy spawn file actions object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawn_file_actions_init "posix_spawn_file_actions_t * file_actions" +.Ft int +.Fn posix_spawn_file_actions_destroy "posix_spawn_file_actions_t * file_actions" +.Sh DESCRIPTION +The +.Fn posix_spawn_file_actions_init +function initialize the object referenced by +.Fn file_actions +to contain no file actions for +.Fn posix_spawn +or +.Fn posix_spawnp . +Initializing an already initialized spawn file actions object may cause +memory to be leaked. +.Pp +The +.Fn posix_spawn_file_actions_destroy +function destroy the object referenced by +.Fa file_actions ; +the object becomes, in effect, uninitialized. +A destroyed spawn file actions object can be reinitialized using +.Fn posix_spawn_file_actions_init . +The object should not be used after it has been destroyed. +.Sh RETURN VALUES +Upon successful completion, these functions return zero; +otherwise, an error number is returned to indicate the error. +.Sh ERRORS +The +.Fn posix_spawn_file_actions_init +function will fail if: +.Bl -tag -width Er +.It Bq Er ENOMEM +Insufficient memory exists to initialize the spawn file actions object. +.El +.Sh SEE ALSO +.Xr posix_spawn 3 , +.Xr posix_spawn_file_actions_addclose 3 , +.Xr posix_spawn_file_actions_adddup2 3 , +.Xr posix_spawn_file_actions_addopen 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawn_file_actions_init +and +.Fn posix_spawn_file_actions_destroy +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawn_file_actions_init +and +.Fn posix_spawn_file_actions_destroy +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getflags.3 b/lib/libc/gen/posix_spawnattr_getflags.3 new file mode 100644 index 0000000000..54fbb09a43 --- /dev/null +++ b/lib/libc/gen/posix_spawnattr_getflags.3 @@ -0,0 +1,111 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getflags.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWNATTR_GETFLAGS 3 +.Os +.Sh NAME +.Nm posix_spawnattr_getflags , +.Nm posix_spawnattr_setflags +.Nd "get and set the spawn-flags attribute of a spawn attributes object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawnattr_getflags "const posix_spawnattr_t *restrict attr" "short *restrict flags" +.Ft int +.Fn posix_spawnattr_setflags "posix_spawnattr_t *attr" "short flags" +.Sh DESCRIPTION +The +.Fn posix_spawnattr_getflags +function obtains the value of the spawn-flags attribute from the +attributes object referenced by +.Fa attr . +.Pp +The +.Fn posix_spawnattr_setflags +function sets the spawn-flags attribute in an initialized +attributes object referenced by +.Fa attr . +.Pp +The spawn-flags attribute is used to indicate which process attributes +are to be changed in the new process image when invoking +.Fn posix_spawn +or +.Fn posix_spawnp . +It is the bitwise-inclusive OR of zero or more of the following flags +(see +.Fn posix_spawn ) : +.Bl -tag -offset indent +.It Dv POSIX_SPAWN_RESETIDS +.It Dv POSIX_SPAWN_SETPGROUP +.It Dv POSIX_SPAWN_SETSIGDEF +.It Dv POSIX_SPAWN_SETSIGMASK +.It Dv POSIX_SPAWN_SETSCHEDPARAM +.It Dv POSIX_SPAWN_SETSCHEDULER +.El +.Pp +These flags are defined in +.In spawn.h . +The default value of this attribute is as if no flags were set. +.Sh RETURN VALUES +The +.Fn posix_spawnattr_getflags +and +.Fn posix_spawnattr_setflags +functions return zero. +.Sh SEE ALSO +.Xr posix_spawn 3 , +.Xr posix_spawnattr_destroy 3 , +.Xr posix_spawnattr_init 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawnattr_getflags +and +.Fn posix_spawnattr_setflags +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawnattr_getflags +and +.Fn posix_spawnattr_setflags +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getpgroup.3 b/lib/libc/gen/posix_spawnattr_getpgroup.3 new file mode 100644 index 0000000000..2945df943c --- /dev/null +++ b/lib/libc/gen/posix_spawnattr_getpgroup.3 @@ -0,0 +1,96 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getpgroup.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWNATTR_GETPGROUP 3 +.Os +.Sh NAME +.Nm posix_spawnattr_getpgroup , +.Nm posix_spawnattr_setpgroup +.Nd "get and set the spawn-pgroup attribute of a spawn attributes object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawnattr_getpgroup "const posix_spawnattr_t *restrict attr" "pid_t *restrict pgroup" +.Ft int +.Fn posix_spawnattr_setpgroup "posix_spawnattr_t *attr" "pid_t pgroup" +.Sh DESCRIPTION +The +.Fn posix_spawnattr_getpgroup +function obtains the value of the spawn-pgroup attribute from the +attributes object referenced by +.Fa attr . +.Pp +The +.Fn posix_spawnattr_setpgroup +function sets the spawn-pgroup attribute in an initialized +attributes object referenced by +.Fa attr . +.Pp +The spawn-pgroup attribute represents the process group to be joined by +the new process image in a spawn operation (if +.Dv POSIX_SPAWN_SETPGROUP +is set in the spawn-flags attribute). +The default value of this attribute is zero. +.Sh RETURN VALUES +The +.Fn posix_spawnattr_getpgroup +and +.Fn posix_spawnattr_setpgroup +functions return zero. +.Sh SEE ALSO +.Xr posix_spawn 3 , +.Xr posix_spawnattr_destroy 3 , +.Xr posix_spawnattr_init 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawnattr_getpgroup +and +.Fn posix_spawnattr_setpgroup +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawnattr_getpgroup +and +.Fn posix_spawnattr_setpgroup +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getschedparam.3 b/lib/libc/gen/posix_spawnattr_getschedparam.3 new file mode 100644 index 0000000000..fc9e9e7b49 --- /dev/null +++ b/lib/libc/gen/posix_spawnattr_getschedparam.3 @@ -0,0 +1,100 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getschedparam.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWNATTR_GETSCHEDPARAM 3 +.Os +.Sh NAME +.Nm posix_spawnattr_getschedparam , +.Nm posix_spawnattr_setschedparam +.Nd "get and set the spawn-schedparam attribute of a spawn attributes object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawnattr_getschedparam "const posix_spawnattr_t *restrict attr" "struct sched_param *restrict schedparam" +.Ft int +.Fn posix_spawnattr_setschedparam "posix_spawnattr_t *attr" "const struct sched_param *restrict schedparam" +.Sh DESCRIPTION +The +.Fn posix_spawnattr_getschedparam +function obtains the value of the spawn-schedparam attribute from the +attributes object referenced by +.Fa attr . +.Pp +The +.Fn posix_spawnattr_setschedparam +function sets the spawn-schedparam attribute in an initialized attributes +object referenced by +.Fa attr . +.Pp +The spawn-schedparam attribute represents the scheduling parameters to +be assigned to the new process image in a spawn operation (if +.Dv POSIX_SPAWN_SETSCHEDULER +or +.Dv POSIX_SPAWN_SETSCHEDPARAM +is set in the spawn-flags attribute). +The default value of this attribute is unspecified. +.Sh RETURN VALUES +The +.Fn posix_spawnattr_getschedparam +and +.Fn posix_spawnattr_setschedparam +functions return zero. +.Sh SEE ALSO +.Xr posix_spawn 3 , +.Xr posix_spawnattr_destroy 3 , +.Xr posix_spawnattr_getschedpolicy 3 , +.Xr posix_spawnattr_init 3 , +.Xr posix_spawnattr_setschedpolicy 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawnattr_getschedparam +and +.Fn posix_spawnattr_setschedparam +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawnattr_getschedparam +and +.Fn posix_spawnattr_setschedparam +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getschedpolicy.3 b/lib/libc/gen/posix_spawnattr_getschedpolicy.3 new file mode 100644 index 0000000000..48d6115edd --- /dev/null +++ b/lib/libc/gen/posix_spawnattr_getschedpolicy.3 @@ -0,0 +1,98 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getschedpolicy.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWNATTR_GETSCHEDPOLICY 3 +.Os +.Sh NAME +.Nm posix_spawnattr_getschedpolicy , +.Nm posix_spawnattr_setschedpolicy +.Nd "get and set the spawn-schedpolicy attribute of a spawn attributes object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawnattr_getschedpolicy "const posix_spawnattr_t *restrict attr" "int *restrict schedpolicy" +.Ft int +.Fn posix_spawnattr_setschedpolicy "posix_spawnattr_t *attr" "int schedpolicy" +.Sh DESCRIPTION +The +.Fn posix_spawnattr_getschedpolicy +function obtains the value of the spawn-schedpolicy attribute from the +attributes object referenced by +.Fa attr . +.Pp +The +.Fn posix_spawnattr_setschedpolicy +function sets the spawn-schedpolicy attribute in an initialized attributes +object referenced by +.Fa attr . +.Pp +The spawn-schedpolicy attribute represents the scheduling policy to +be assigned to the new process image in a spawn operation (if +.Dv POSIX_SPAWN_SETSCHEDULER +is set in the spawn-flags attribute). +The default value of this attribute is unspecified. +.Sh RETURN VALUES +The +.Fn posix_spawnattr_getschedpolicy +and +.Fn posix_spawnattr_setschedpolicy +functions return zero. +.Sh SEE ALSO +.Xr posix_spawn 3 , +.Xr posix_spawnattr_destroy 3 , +.Xr posix_spawnattr_getschedparam 3 , +.Xr posix_spawnattr_init 3 , +.Xr posix_spawnattr_setschedparam 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawnattr_getschedpolicy +and +.Fn posix_spawnattr_setschedpolicy +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawnattr_getschedpolicy +and +.Fn posix_spawnattr_setschedpolicy +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getsigdefault.3 b/lib/libc/gen/posix_spawnattr_getsigdefault.3 new file mode 100644 index 0000000000..ae789f6457 --- /dev/null +++ b/lib/libc/gen/posix_spawnattr_getsigdefault.3 @@ -0,0 +1,98 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getsigdefault.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWNATTR_GETSIGDEFAULT 3 +.Os +.Sh NAME +.Nm posix_spawnattr_getsigdefault , +.Nm posix_spawnattr_setsigdefault +.Nd "get and set the spawn-sigdefault attribute of a spawn attributes object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawnattr_getsigdefault "const posix_spawnattr_t *restrict attr" "sigset_t *restrict sigdefault" +.Ft int +.Fn posix_spawnattr_setsigdefault "posix_spawnattr_t *attr" "const sigset_t *restrict sigdefault" +.Sh DESCRIPTION +The +.Fn posix_spawnattr_getsigdefault +function obtains the value of the spawn-sigdefault attribute from the +attributes object referenced by +.Fa attr . +.Pp +The +.Fn posix_spawnattr_setsigdefault +function sets the spawn-sigdefault attribute in an initialized attributes +object referenced by +.Fa attr . +.Pp +The spawn-sigdefault attribute represents the set of signals to be forced to +default signal handling in the new process image (if +.Dv POSIX_SPAWN_SETSIGDEF +is set in the spawn-flags attribute) by a spawn operation. +The default value of this attribute is an empty signal set. +.Sh RETURN VALUES +The +.Fn posix_spawnattr_getsigdefault +and +.Fn posix_spawnattr_setsigdefault +functions return zero. +.Sh SEE ALSO +.Xr posix_spawn 3 , +.Xr posix_spawnattr_destroy 3 , +.Xr posix_spawnattr_getsigmask 3 , +.Xr posix_spawnattr_init 3 , +.Xr posix_spawnattr_setsigmask 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawnattr_getsigdefault +and +.Fn posix_spawnattr_setsigdefault +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawnattr_getsigdefault +and +.Fn posix_spawnattr_setsigdefault +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getsigmask.3 b/lib/libc/gen/posix_spawnattr_getsigmask.3 new file mode 100644 index 0000000000..c7211a1b6a --- /dev/null +++ b/lib/libc/gen/posix_spawnattr_getsigmask.3 @@ -0,0 +1,98 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getsigmask.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWNATTR_GETSIGMASK 3 +.Os +.Sh NAME +.Nm posix_spawnattr_getsigmask , +.Nm posix_spawnattr_setsigmask +.Nd "get and set the spawn-sigmask attribute of a spawn attributes object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawnattr_getsigmask "const posix_spawnattr_t *restrict attr" "sigset_t *restrict sigmask" +.Ft int +.Fn posix_spawnattr_setsigmask "posix_spawnattr_t *attr" "const sigset_t *restrict sigmask" +.Sh DESCRIPTION +The +.Fn posix_spawnattr_getsigmask +function obtains the value of the spawn-sigmask attribute from the +attributes object referenced by +.Fa attr . +.Pp +The +.Fn posix_spawnattr_setsigmask +function sets the spawn-sigmask attribute in an initialized attributes +object referenced by +.Fa attr . +.Pp +The spawn-sigmask attribute represents the signal mask in effect in the +new process image of a spawn operation (if +.Dv POSIX_SPAWN_SETSIGMASK +is set in the spawn-flags attribute). +The default value of this attribute is unspecified. +.Sh RETURN VALUES +The +.Fn posix_spawnattr_getsigmask +and +.Fn posix_spawnattr_setsigmask +functions return zero. +.Sh SEE ALSO +.Xr posix_spawn 3 , +.Xr posix_spawnattr_destroy 3 , +.Xr posix_spawnattr_getsigmask 3 , +.Xr posix_spawnattr_init 3 , +.Xr posix_spawnattr_setsigmask 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawnattr_getsigmask +and +.Fn posix_spawnattr_setsigmask +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawnattr_getsigmask +and +.Fn posix_spawnattr_setsigmask +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_init.3 b/lib/libc/gen/posix_spawnattr_init.3 new file mode 100644 index 0000000000..1a09bedc77 --- /dev/null +++ b/lib/libc/gen/posix_spawnattr_init.3 @@ -0,0 +1,123 @@ +.\" Copyright (c) 2008 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_init.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $ +.\" +.Dd Mar 24, 2008 +.Dt POSIX_SPAWNATTR_INIT 3 +.Os +.Sh NAME +.Nm posix_spawnattr_init , +.Nm posix_spawnattr_destroy +.Nd "initialize and destroy spawn attributes object" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In spawn.h +.Ft int +.Fn posix_spawnattr_init "posix_spawnattr_t * attr" +.Ft int +.Fn posix_spawnattr_destroy "posix_spawnattr_t * attr" +.Sh DESCRIPTION +The +.Fn posix_spawnattr_init +function initializes a spawn attributes object +.Fa attr +with the default value for all of the individual attributes used by the +implementation. +Initializing an already initialized spawn attributes object may cause +memory to be leaked. +.Pp +The +.Fn posix_spawnattr_destroy +function destroys a spawn attributes object. +A destroyed +.Fa attr +attributes object can be reinitialized using +.Fn posix_spawnattr_init . +The object should not be used after it has been destroyed. +.Pp +A spawn attributes object is of type +.Vt posix_spawnattr_t +(defined in +.In spawn.h ) +and is used to specify the inheritance of process attributes across a +spawn operation. +.Pp +The resulting spawn attributes object (possibly modified by setting +individual attribute values), is used to modify the behavior of +.Fn posix_spawn +or +.Fn posix_spawnp . +After a spawn attributes object has been used to spawn a process by a +call to a +.Fn posix_spawn +or +.Fn posix_spawnp , +any function affecting the attributes object (including destruction) +will not affect any process that has been spawned in this way. +.Sh RETURN VALUES +Upon successful completion, +.Fn posix_spawnattr_init +and +.Fn posix_spawnattr_destroy +return zero; +otherwise, an error number is returned to indicate the error. +.Sh ERRORS +The +.Fn posix_spawnattr_init +function will fail if: +.Bl -tag -width Er +.It Bq Er ENOMEM +Insufficient memory exists to initialize the spawn file actions object. +.El +.Sh SEE ALSO +.Xr posix_spawn 3 , +.Xr posix_spawnp 3 +.Sh STANDARDS +The +.Fn posix_spawnattr_init +and +.Fn posix_spawnattr_destroy +functions conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn posix_spawnattr_init +and +.Fn posix_spawnattr_destroy +functions first appeared in +.Fx 8.0 . +.Sh AUTHORS +.An Ed Schouten Aq ed@FreeBSD.org diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index 962ab6bbe6..18a8e49d8b 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -92,4 +92,7 @@ extern const char *__progname; */ extern void (*__cleanup)(void); +/* execve() with PATH processing to implement posix_spawnp() */ +int _execvpe(const char *, char * const *, char * const *); + #endif /* _LIBC_PRIVATE_H_ */ -- 2.41.0