17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5657b1f3dSraf * Common Development and Distribution License (the "License"). 6657b1f3dSraf * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21657b1f3dSraf 227c478bd9Sstevel@tonic-gate /* 23*b59b3655SGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 24*b59b3655SGarrett D'Amore * 2508556f6cSRoger A. Faulkner * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate * Use is subject to license terms. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 29462453d2SMatthew Ahrens /* 30462453d2SMatthew Ahrens * Copyright (c) 2011 by Delphix. All rights reserved. 31462453d2SMatthew Ahrens */ 32462453d2SMatthew Ahrens 337c478bd9Sstevel@tonic-gate #ifndef _SPAWN_H 347c478bd9Sstevel@tonic-gate #define _SPAWN_H 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 377c478bd9Sstevel@tonic-gate #include <sys/types.h> 387c478bd9Sstevel@tonic-gate #include <signal.h> 397c478bd9Sstevel@tonic-gate #include <sched.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 427c478bd9Sstevel@tonic-gate extern "C" { 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 45657b1f3dSraf /* 46657b1f3dSraf * flags for posix_spawnattr_setflags() 47657b1f3dSraf */ 48657b1f3dSraf #define POSIX_SPAWN_RESETIDS 0x0001 49657b1f3dSraf #define POSIX_SPAWN_SETPGROUP 0x0002 50657b1f3dSraf #define POSIX_SPAWN_SETSIGDEF 0x0004 51657b1f3dSraf #define POSIX_SPAWN_SETSIGMASK 0x0008 52657b1f3dSraf #define POSIX_SPAWN_SETSCHEDPARAM 0x0010 53657b1f3dSraf #define POSIX_SPAWN_SETSCHEDULER 0x0020 54657b1f3dSraf /* 55657b1f3dSraf * non-portable Solaris extensions 56657b1f3dSraf */ 5703bc411dSRoger A. Faulkner #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 5803bc411dSRoger A. Faulkner #define POSIX_SPAWN_SETSIGIGN_NP 0x0800 59657b1f3dSraf #define POSIX_SPAWN_NOSIGCHLD_NP 0x1000 60657b1f3dSraf #define POSIX_SPAWN_WAITPID_NP 0x2000 61f9f6ed06SRoger A. Faulkner #define POSIX_SPAWN_NOEXECERR_NP 0x4000 6203bc411dSRoger A. Faulkner #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef struct { 657c478bd9Sstevel@tonic-gate void *__spawn_attrp; /* implementation-private */ 667c478bd9Sstevel@tonic-gate } posix_spawnattr_t; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate typedef struct { 697c478bd9Sstevel@tonic-gate void *__file_attrp; /* implementation-private */ 707c478bd9Sstevel@tonic-gate } posix_spawn_file_actions_t; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate extern int posix_spawn( 737c478bd9Sstevel@tonic-gate pid_t *_RESTRICT_KYWD pid, 747c478bd9Sstevel@tonic-gate const char *_RESTRICT_KYWD path, 757c478bd9Sstevel@tonic-gate const posix_spawn_file_actions_t *file_actions, 767c478bd9Sstevel@tonic-gate const posix_spawnattr_t *_RESTRICT_KYWD attrp, 777c478bd9Sstevel@tonic-gate char *const argv[_RESTRICT_KYWD], 787c478bd9Sstevel@tonic-gate char *const envp[_RESTRICT_KYWD]); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate extern int posix_spawnp( 817c478bd9Sstevel@tonic-gate pid_t *_RESTRICT_KYWD pid, 827c478bd9Sstevel@tonic-gate const char *_RESTRICT_KYWD file, 837c478bd9Sstevel@tonic-gate const posix_spawn_file_actions_t *file_actions, 847c478bd9Sstevel@tonic-gate const posix_spawnattr_t *_RESTRICT_KYWD attrp, 857c478bd9Sstevel@tonic-gate char *const argv[_RESTRICT_KYWD], 867c478bd9Sstevel@tonic-gate char *const envp[_RESTRICT_KYWD]); 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_init( 897c478bd9Sstevel@tonic-gate posix_spawn_file_actions_t *file_actions); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_destroy( 927c478bd9Sstevel@tonic-gate posix_spawn_file_actions_t *file_actions); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addopen( 957c478bd9Sstevel@tonic-gate posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions, 967c478bd9Sstevel@tonic-gate int filedes, 977c478bd9Sstevel@tonic-gate const char *_RESTRICT_KYWD path, 987c478bd9Sstevel@tonic-gate int oflag, 997c478bd9Sstevel@tonic-gate mode_t mode); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_addclose( 1027c478bd9Sstevel@tonic-gate posix_spawn_file_actions_t *file_actions, 1037c478bd9Sstevel@tonic-gate int filedes); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate extern int posix_spawn_file_actions_adddup2( 1067c478bd9Sstevel@tonic-gate posix_spawn_file_actions_t *file_actions, 1077c478bd9Sstevel@tonic-gate int filedes, 1087c478bd9Sstevel@tonic-gate int newfiledes); 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate extern int posix_spawnattr_init( 1117c478bd9Sstevel@tonic-gate posix_spawnattr_t *attr); 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate extern int posix_spawnattr_destroy( 1147c478bd9Sstevel@tonic-gate posix_spawnattr_t *attr); 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setflags( 1177c478bd9Sstevel@tonic-gate posix_spawnattr_t *attr, 1187c478bd9Sstevel@tonic-gate short flags); 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getflags( 1217c478bd9Sstevel@tonic-gate const posix_spawnattr_t *_RESTRICT_KYWD attr, 1227c478bd9Sstevel@tonic-gate short *_RESTRICT_KYWD flags); 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setpgroup( 1257c478bd9Sstevel@tonic-gate posix_spawnattr_t *attr, 1267c478bd9Sstevel@tonic-gate pid_t pgroup); 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getpgroup( 1297c478bd9Sstevel@tonic-gate const posix_spawnattr_t *_RESTRICT_KYWD attr, 1307c478bd9Sstevel@tonic-gate pid_t *_RESTRICT_KYWD pgroup); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedparam( 1337c478bd9Sstevel@tonic-gate posix_spawnattr_t *_RESTRICT_KYWD attr, 1347c478bd9Sstevel@tonic-gate const struct sched_param *_RESTRICT_KYWD schedparam); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedparam( 1377c478bd9Sstevel@tonic-gate const posix_spawnattr_t *_RESTRICT_KYWD attr, 1387c478bd9Sstevel@tonic-gate struct sched_param *_RESTRICT_KYWD schedparam); 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setschedpolicy( 1417c478bd9Sstevel@tonic-gate posix_spawnattr_t *attr, 1427c478bd9Sstevel@tonic-gate int schedpolicy); 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getschedpolicy( 1457c478bd9Sstevel@tonic-gate const posix_spawnattr_t *_RESTRICT_KYWD attr, 1467c478bd9Sstevel@tonic-gate int *_RESTRICT_KYWD schedpolicy); 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigdefault( 1497c478bd9Sstevel@tonic-gate posix_spawnattr_t *_RESTRICT_KYWD attr, 1507c478bd9Sstevel@tonic-gate const sigset_t *_RESTRICT_KYWD sigdefault); 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigdefault( 1537c478bd9Sstevel@tonic-gate const posix_spawnattr_t *_RESTRICT_KYWD attr, 1547c478bd9Sstevel@tonic-gate sigset_t *_RESTRICT_KYWD sigdefault); 1557c478bd9Sstevel@tonic-gate 15603bc411dSRoger A. Faulkner /* 15703bc411dSRoger A. Faulkner * non-portable Solaris extensions 15803bc411dSRoger A. Faulkner */ 15903bc411dSRoger A. Faulkner #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 16003bc411dSRoger A. Faulkner 161462453d2SMatthew Ahrens extern int posix_spawn_pipe_np( 162462453d2SMatthew Ahrens pid_t *_RESTRICT_KYWD pidp, 163462453d2SMatthew Ahrens int *_RESTRICT_KYWD fdp, 164462453d2SMatthew Ahrens const char *_RESTRICT_KYWD cmd, 165462453d2SMatthew Ahrens boolean_t write, 166462453d2SMatthew Ahrens posix_spawn_file_actions_t *_RESTRICT_KYWD fact, 167462453d2SMatthew Ahrens posix_spawnattr_t *_RESTRICT_KYWD attr); 168462453d2SMatthew Ahrens 16908556f6cSRoger A. Faulkner extern int posix_spawn_file_actions_addclosefrom_np( 17008556f6cSRoger A. Faulkner posix_spawn_file_actions_t *file_actions, 17108556f6cSRoger A. Faulkner int lowfiledes); 17208556f6cSRoger A. Faulkner 17303bc411dSRoger A. Faulkner extern int posix_spawnattr_setsigignore_np( 17403bc411dSRoger A. Faulkner posix_spawnattr_t *_RESTRICT_KYWD attr, 17503bc411dSRoger A. Faulkner const sigset_t *_RESTRICT_KYWD sigignore); 17603bc411dSRoger A. Faulkner 17703bc411dSRoger A. Faulkner extern int posix_spawnattr_getsigignore_np( 17803bc411dSRoger A. Faulkner const posix_spawnattr_t *_RESTRICT_KYWD attr, 17903bc411dSRoger A. Faulkner sigset_t *_RESTRICT_KYWD sigignore); 18003bc411dSRoger A. Faulkner 18103bc411dSRoger A. Faulkner #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 18203bc411dSRoger A. Faulkner 1837c478bd9Sstevel@tonic-gate extern int posix_spawnattr_setsigmask( 1847c478bd9Sstevel@tonic-gate posix_spawnattr_t *_RESTRICT_KYWD attr, 1857c478bd9Sstevel@tonic-gate const sigset_t *_RESTRICT_KYWD sigmask); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate extern int posix_spawnattr_getsigmask( 1887c478bd9Sstevel@tonic-gate const posix_spawnattr_t *_RESTRICT_KYWD attr, 1897c478bd9Sstevel@tonic-gate sigset_t *_RESTRICT_KYWD sigmask); 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1927c478bd9Sstevel@tonic-gate } 1937c478bd9Sstevel@tonic-gate #endif 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate #endif /* _SPAWN_H */ 196