Skip to content

Commit e943c98

Browse files
sunshowerstgross35
authored andcommitted
[solarish/illumos] add the posix_spawn family of functions
Add definitions from `spawn.h` as present [in illumos-gate (blame view)][spawn-h]. I added definitions more than 15 years old to `solarish/mod.rs`, and others to `solarish/illumos.rs`. There are a lot of definitions here -- it's easiest to look at them in the blame view linked above. But here are the corresponding man pages: For solarish: * [`posix_spawn`, `posix_spawnp`](https://illumos.org/man/3C/posix_spawn) * [`posix_spawn_file_actions_{init,destroy}`](https://illumos.org/man/3C/posix_spawn_file_actions_init) * [`posix_spawn_file_actions_{addopen,addclose}`](https://illumos.org/man/3C/posix_spawn_file_actions_addopen) * [`posix_spawn_file_actions_adddup2`](https://illumos.org/man/3C/posix_spawn_file_actions_adddup2) * [`posix_spawn_file_actions_addclosefrom_np`](https://illumos.org/man/3C/posix_spawn_file_actions_addclosefrom_np) * [`posix_spawnattr_{init,destroy}`](https://illumos.org/man/3C/posix_spawnattr_init) * [`posix_spawnattr_{setflags,getflags}`](https://illumos.org/man/3C/posix_spawnattr_setflags) * [`posix_spawnattr_{setpgroup,getpgroup}`](https://illumos.org/man/3C/posix_spawnattr_setpgroup) * [`posix_spawnattr_{setschedparam,getschedparam}`](https://illumos.org/man/3C/posix_spawnattr_setschedparam) * [`posix_spawnattr_{setschedpolicy,getschedpolicy}`](https://illumos.org/man/3C/posix_spawnattr_setschedpolicy) * [`posix_spawnattr_{setsigdefault,getsigdefault}`](https://illumos.org/man/3C/posix_spawnattr_setsigdefault) * [`posix_spawnattr_{setsigignore,getsigignore}_np`](https://illumos.org/man/3C/posix_spawnattr_setsigignore_np) * [`posix_spawnattr_{setsigmask,getsigmask}`](https://illumos.org/man/3C/posix_spawnattr_setsigmask) Newer functions added independently to Solaris and illumos: * [`posix_spawn_file_actions_{addchdir,addchdir_np,addfchdir}` on Solaris](https://docs.oracle.com/cd/E88353_01/html/E37843/posix-spawn-file-actions-addchdir-np-3c.html) * The illumos-only functions are quite recent so the man pages haven't been uploaded to illumos.org yet. But [here's the one for `addchdir` and `addfchdir`](https://github.com/illumos/illumos-gate/blob/7633a05bff8c639f2df722d1fba7b889b2763d3d/usr/src/man/man3c/posix_spawn_file_actions_addchdir.3c). Note that the `_np` functions are not documented in the manual, but they are available for compatibility. The one function I skipped over was [`posix_spawn_pipe_np`](https://illumos.org/man/3C/posix_spawn_pipe_np) -- it seemed a bit niche and I wasn't quite sure how to model `boolean_t`. [spawn-h]: https://github.com/illumos/illumos-gate/blame/7633a05bff8c639f2df722d1fba7b889b2763d3d/usr/src/head/spawn.h#L1 (backport <#4259>) (cherry picked from commit 162e306)
1 parent 81c931f commit e943c98

File tree

6 files changed

+163
-0
lines changed

6 files changed

+163
-0
lines changed

libc-test/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ fn test_solarish(target: &str) {
915915
"sched.h",
916916
"semaphore.h",
917917
"signal.h",
918+
"spawn.h",
918919
"stddef.h",
919920
"stdint.h",
920921
"stdio.h",

libc-test/semver/illumos.txt

+2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ POSIX_FADV_NORMAL
1414
POSIX_FADV_RANDOM
1515
POSIX_FADV_SEQUENTIAL
1616
POSIX_FADV_WILLNEED
17+
POSIX_SPAWN_SETSID
1718
posix_fadvise
1819
posix_fallocate
20+
posix_spawn_file_actions_addfchdir_np
1921
pthread_attr_get_np
2022
pthread_attr_getstackaddr
2123
pthread_attr_setstack

libc-test/semver/solarish.txt

+37
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ LIO_READ
1515
LIO_WAIT
1616
LIO_WRITE
1717
PIPE_BUF
18+
POSIX_SPAWN_NOEXECERR_NP
19+
POSIX_SPAWN_NOSIGCHLD_NP
20+
POSIX_SPAWN_RESETIDS
21+
POSIX_SPAWN_SETPGROUP
22+
POSIX_SPAWN_SETSCHEDPARAM
23+
POSIX_SPAWN_SETSCHEDULER
24+
POSIX_SPAWN_SETSIGDEF
25+
POSIX_SPAWN_SETSIGIGN_NP
26+
POSIX_SPAWN_SETSIGMASK
27+
POSIX_SPAWN_WAITPID_NP
1828
SIGEV_PORT
1929
SIGRTMAX
2030
SIGRTMIN
@@ -34,5 +44,32 @@ bind
3444
in6_pktinfo
3545
in_pktinfo
3646
lio_listio
47+
posix_spawn
48+
posix_spawn_file_actions_addchdir
49+
posix_spawn_file_actions_addchdir_np
50+
posix_spawn_file_actions_addclose
51+
posix_spawn_file_actions_addclosefrom_np
52+
posix_spawn_file_actions_adddup2
53+
posix_spawn_file_actions_addfchdir
54+
posix_spawn_file_actions_addopen
55+
posix_spawn_file_actions_destroy
56+
posix_spawn_file_actions_init
57+
posix_spawnattr_destroy
58+
posix_spawnattr_getflags
59+
posix_spawnattr_getpgroup
60+
posix_spawnattr_getschedparam
61+
posix_spawnattr_getschedpolicy
62+
posix_spawnattr_getsigdefault
63+
posix_spawnattr_getsigignore_np
64+
posix_spawnattr_getsigmask
65+
posix_spawnattr_init
66+
posix_spawnattr_setflags
67+
posix_spawnattr_setpgroup
68+
posix_spawnattr_setschedparam
69+
posix_spawnattr_setschedpolicy
70+
posix_spawnattr_setsigdefault
71+
posix_spawnattr_setsigignore_np
72+
posix_spawnattr_setsigmask
73+
posix_spawnp
3774
recvmsg
3875
sendmsg

src/unix/solarish/illumos.rs

+7
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ pub const POSIX_FADV_WILLNEED: c_int = 3;
205205
pub const POSIX_FADV_DONTNEED: c_int = 4;
206206
pub const POSIX_FADV_NOREUSE: c_int = 5;
207207

208+
pub const POSIX_SPAWN_SETSID: c_short = 0x40;
209+
208210
pub const SIGINFO: c_int = 41;
209211

210212
pub const O_DIRECT: c_int = 0x2000000;
@@ -335,6 +337,11 @@ extern "C" {
335337
pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
336338
pub fn getpagesizes2(pagesize: *mut size_t, nelem: c_int) -> c_int;
337339

340+
pub fn posix_spawn_file_actions_addfchdir_np(
341+
file_actions: *mut crate::posix_spawn_file_actions_t,
342+
fd: c_int,
343+
) -> c_int;
344+
338345
pub fn ptsname_r(fildes: c_int, name: *mut c_char, namelen: size_t) -> c_int;
339346

340347
pub fn syncfs(fd: c_int) -> c_int;

src/unix/solarish/mod.rs

+114
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ pub type lgrp_lat_between_t = c_uint;
5656
pub type lgrp_mem_size_flag_t = c_uint;
5757
pub type lgrp_view_t = c_uint;
5858

59+
pub type posix_spawnattr_t = *mut c_void;
60+
pub type posix_spawn_file_actions_t = *mut c_void;
61+
5962
#[cfg_attr(feature = "extra_traits", derive(Debug))]
6063
pub enum timezone {}
6164
impl Copy for timezone {}
@@ -1543,6 +1546,17 @@ pub const POSIX_MADV_SEQUENTIAL: c_int = 2;
15431546
pub const POSIX_MADV_WILLNEED: c_int = 3;
15441547
pub const POSIX_MADV_DONTNEED: c_int = 4;
15451548

1549+
pub const POSIX_SPAWN_RESETIDS: c_short = 0x1;
1550+
pub const POSIX_SPAWN_SETPGROUP: c_short = 0x2;
1551+
pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x4;
1552+
pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x8;
1553+
pub const POSIX_SPAWN_SETSCHEDPARAM: c_short = 0x10;
1554+
pub const POSIX_SPAWN_SETSCHEDULER: c_short = 0x20;
1555+
pub const POSIX_SPAWN_SETSIGIGN_NP: c_short = 0x800;
1556+
pub const POSIX_SPAWN_NOSIGCHLD_NP: c_short = 0x1000;
1557+
pub const POSIX_SPAWN_WAITPID_NP: c_short = 0x2000;
1558+
pub const POSIX_SPAWN_NOEXECERR_NP: c_short = 0x4000;
1559+
15461560
pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
15471561
pub const PTHREAD_CREATE_DETACHED: c_int = 0x40;
15481562
pub const PTHREAD_PROCESS_SHARED: c_int = 1;
@@ -2688,6 +2702,106 @@ extern "C" {
26882702
pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
26892703
pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
26902704

2705+
pub fn posix_spawn(
2706+
pid: *mut crate::pid_t,
2707+
path: *const c_char,
2708+
file_actions: *const posix_spawn_file_actions_t,
2709+
attrp: *const posix_spawnattr_t,
2710+
argv: *const *mut c_char,
2711+
envp: *const *mut c_char,
2712+
) -> c_int;
2713+
pub fn posix_spawnp(
2714+
pid: *mut crate::pid_t,
2715+
file: *const c_char,
2716+
file_actions: *const posix_spawn_file_actions_t,
2717+
attrp: *const posix_spawnattr_t,
2718+
argv: *const *mut c_char,
2719+
envp: *const *mut c_char,
2720+
) -> c_int;
2721+
2722+
pub fn posix_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> c_int;
2723+
pub fn posix_spawn_file_actions_destroy(file_actions: *mut posix_spawn_file_actions_t)
2724+
-> c_int;
2725+
pub fn posix_spawn_file_actions_addopen(
2726+
file_actions: *mut posix_spawn_file_actions_t,
2727+
fildes: c_int,
2728+
path: *const c_char,
2729+
oflag: c_int,
2730+
mode: crate::mode_t,
2731+
) -> c_int;
2732+
pub fn posix_spawn_file_actions_addclose(
2733+
file_actions: *mut posix_spawn_file_actions_t,
2734+
fildes: c_int,
2735+
) -> c_int;
2736+
pub fn posix_spawn_file_actions_adddup2(
2737+
file_actions: *mut posix_spawn_file_actions_t,
2738+
fildes: c_int,
2739+
newfildes: c_int,
2740+
) -> c_int;
2741+
pub fn posix_spawn_file_actions_addclosefrom_np(
2742+
file_actions: *mut posix_spawn_file_actions_t,
2743+
lowfiledes: c_int,
2744+
) -> c_int;
2745+
pub fn posix_spawn_file_actions_addchdir(
2746+
file_actions: *mut posix_spawn_file_actions_t,
2747+
path: *const c_char,
2748+
) -> c_int;
2749+
pub fn posix_spawn_file_actions_addchdir_np(
2750+
file_actions: *mut posix_spawn_file_actions_t,
2751+
path: *const c_char,
2752+
) -> c_int;
2753+
pub fn posix_spawn_file_actions_addfchdir(
2754+
file_actions: *mut posix_spawn_file_actions_t,
2755+
fd: c_int,
2756+
) -> c_int;
2757+
2758+
pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
2759+
pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
2760+
pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
2761+
pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int;
2762+
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: crate::pid_t) -> c_int;
2763+
pub fn posix_spawnattr_getpgroup(
2764+
attr: *const posix_spawnattr_t,
2765+
_pgroup: *mut crate::pid_t,
2766+
) -> c_int;
2767+
pub fn posix_spawnattr_setschedparam(
2768+
attr: *mut posix_spawnattr_t,
2769+
param: *const crate::sched_param,
2770+
) -> c_int;
2771+
pub fn posix_spawnattr_getschedparam(
2772+
attr: *const posix_spawnattr_t,
2773+
param: *mut crate::sched_param,
2774+
) -> c_int;
2775+
pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, policy: c_int) -> c_int;
2776+
pub fn posix_spawnattr_getschedpolicy(
2777+
attr: *const posix_spawnattr_t,
2778+
_policy: *mut c_int,
2779+
) -> c_int;
2780+
pub fn posix_spawnattr_setsigdefault(
2781+
attr: *mut posix_spawnattr_t,
2782+
sigdefault: *const sigset_t,
2783+
) -> c_int;
2784+
pub fn posix_spawnattr_getsigdefault(
2785+
attr: *const posix_spawnattr_t,
2786+
sigdefault: *mut sigset_t,
2787+
) -> c_int;
2788+
pub fn posix_spawnattr_setsigignore_np(
2789+
attr: *mut posix_spawnattr_t,
2790+
sigignore: *const sigset_t,
2791+
) -> c_int;
2792+
pub fn posix_spawnattr_getsigignore_np(
2793+
attr: *const posix_spawnattr_t,
2794+
sigignore: *mut sigset_t,
2795+
) -> c_int;
2796+
pub fn posix_spawnattr_setsigmask(
2797+
attr: *mut posix_spawnattr_t,
2798+
sigmask: *const sigset_t,
2799+
) -> c_int;
2800+
pub fn posix_spawnattr_getsigmask(
2801+
attr: *const posix_spawnattr_t,
2802+
sigmask: *mut sigset_t,
2803+
) -> c_int;
2804+
26912805
pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void;
26922806

26932807
pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;

src/unix/solarish/solaris.rs

+2
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ pub const PRIV_TPD_UNSAFE: c_uint = 0x0800;
189189
pub const PRIV_PROC_TPD_RESET: c_uint = 0x1000;
190190
pub const PRIV_TPD_KILLABLE: c_uint = 0x2000;
191191

192+
pub const POSIX_SPAWN_SETSID: c_short = 0x400;
193+
192194
pub const PRIV_USER: c_uint = PRIV_DEBUG
193195
| PRIV_PROC_SENSITIVE
194196
| NET_MAC_AWARE

0 commit comments

Comments
 (0)