Skip to content

[solarish/illumos] add the posix_spawn family of functions #4259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ fn test_solarish(target: &str) {
"sched.h",
"semaphore.h",
"signal.h",
"spawn.h",
"stddef.h",
"stdint.h",
"stdio.h",
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/illumos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ POSIX_FADV_NORMAL
POSIX_FADV_RANDOM
POSIX_FADV_SEQUENTIAL
POSIX_FADV_WILLNEED
POSIX_SPAWN_SETSID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solaris 11.4 does have POSIX_SPAWN_SETSID too. But it's different number:

grep POSIX_SPAWN_SETSID /usr/include/sys/spawn.h
#define POSIX_SPAWN_SETSID              0x0400
#define POSIX_SPAWN_SETSID_NP           POSIX_SPAWN_SETSID /* pre-standard */

So I think it's ok to keep it separately as you have it.

posix_fadvise
posix_fallocate
posix_spawn_file_actions_addfchdir_np
pthread_attr_get_np
pthread_attr_getstackaddr
pthread_attr_setstack
Expand Down
37 changes: 37 additions & 0 deletions libc-test/semver/solarish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ LIO_READ
LIO_WAIT
LIO_WRITE
PIPE_BUF
POSIX_SPAWN_NOEXECERR_NP
POSIX_SPAWN_NOSIGCHLD_NP
POSIX_SPAWN_RESETIDS
POSIX_SPAWN_SETPGROUP
POSIX_SPAWN_SETSCHEDPARAM
POSIX_SPAWN_SETSCHEDULER
POSIX_SPAWN_SETSIGDEF
POSIX_SPAWN_SETSIGIGN_NP
POSIX_SPAWN_SETSIGMASK
POSIX_SPAWN_WAITPID_NP
SIGEV_PORT
SIGRTMAX
SIGRTMIN
Expand All @@ -37,5 +47,32 @@ bind
in6_pktinfo
in_pktinfo
lio_listio
posix_spawn
posix_spawn_file_actions_addchdir
posix_spawn_file_actions_addchdir_np
posix_spawn_file_actions_addclose
posix_spawn_file_actions_addclosefrom_np
posix_spawn_file_actions_adddup2
posix_spawn_file_actions_addfchdir
posix_spawn_file_actions_addopen
posix_spawn_file_actions_destroy
posix_spawn_file_actions_init
posix_spawnattr_destroy
posix_spawnattr_getflags
posix_spawnattr_getpgroup
posix_spawnattr_getschedparam
posix_spawnattr_getschedpolicy
posix_spawnattr_getsigdefault
posix_spawnattr_getsigignore_np
posix_spawnattr_getsigmask
posix_spawnattr_init
posix_spawnattr_setflags
posix_spawnattr_setpgroup
posix_spawnattr_setschedparam
posix_spawnattr_setschedpolicy
posix_spawnattr_setsigdefault
posix_spawnattr_setsigignore_np
posix_spawnattr_setsigmask
posix_spawnp
recvmsg
sendmsg
7 changes: 7 additions & 0 deletions src/unix/solarish/illumos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ pub const POSIX_FADV_WILLNEED: c_int = 3;
pub const POSIX_FADV_DONTNEED: c_int = 4;
pub const POSIX_FADV_NOREUSE: c_int = 5;

pub const POSIX_SPAWN_SETSID: c_short = 0x40;

pub const SIGINFO: c_int = 41;

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

pub fn posix_spawn_file_actions_addfchdir_np(
file_actions: *mut crate::posix_spawn_file_actions_t,
fd: c_int,
) -> c_int;

pub fn ptsname_r(fildes: c_int, name: *mut c_char, namelen: size_t) -> c_int;

pub fn syncfs(fd: c_int) -> c_int;
Expand Down
114 changes: 114 additions & 0 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ pub type lgrp_lat_between_t = c_uint;
pub type lgrp_mem_size_flag_t = c_uint;
pub type lgrp_view_t = c_uint;

pub type posix_spawnattr_t = *mut c_void;
pub type posix_spawn_file_actions_t = *mut c_void;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl Copy for timezone {}
Expand Down Expand Up @@ -1541,6 +1544,17 @@ pub const POSIX_MADV_SEQUENTIAL: c_int = 2;
pub const POSIX_MADV_WILLNEED: c_int = 3;
pub const POSIX_MADV_DONTNEED: c_int = 4;

pub const POSIX_SPAWN_RESETIDS: c_short = 0x1;
pub const POSIX_SPAWN_SETPGROUP: c_short = 0x2;
pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x4;
pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x8;
pub const POSIX_SPAWN_SETSCHEDPARAM: c_short = 0x10;
pub const POSIX_SPAWN_SETSCHEDULER: c_short = 0x20;
pub const POSIX_SPAWN_SETSIGIGN_NP: c_short = 0x800;
pub const POSIX_SPAWN_NOSIGCHLD_NP: c_short = 0x1000;
pub const POSIX_SPAWN_WAITPID_NP: c_short = 0x2000;
pub const POSIX_SPAWN_NOEXECERR_NP: c_short = 0x4000;

pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
pub const PTHREAD_CREATE_DETACHED: c_int = 0x40;
pub const PTHREAD_PROCESS_SHARED: c_int = 1;
Expand Down Expand Up @@ -2686,6 +2700,106 @@ extern "C" {
pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;

pub fn posix_spawn(
pid: *mut crate::pid_t,
path: *const c_char,
file_actions: *const posix_spawn_file_actions_t,
attrp: *const posix_spawnattr_t,
argv: *const *mut c_char,
envp: *const *mut c_char,
) -> c_int;
pub fn posix_spawnp(
pid: *mut crate::pid_t,
file: *const c_char,
file_actions: *const posix_spawn_file_actions_t,
attrp: *const posix_spawnattr_t,
argv: *const *mut c_char,
envp: *const *mut c_char,
) -> c_int;

pub fn posix_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> c_int;
pub fn posix_spawn_file_actions_destroy(file_actions: *mut posix_spawn_file_actions_t)
-> c_int;
pub fn posix_spawn_file_actions_addopen(
file_actions: *mut posix_spawn_file_actions_t,
fildes: c_int,
path: *const c_char,
oflag: c_int,
mode: crate::mode_t,
) -> c_int;
pub fn posix_spawn_file_actions_addclose(
file_actions: *mut posix_spawn_file_actions_t,
fildes: c_int,
) -> c_int;
pub fn posix_spawn_file_actions_adddup2(
file_actions: *mut posix_spawn_file_actions_t,
fildes: c_int,
newfildes: c_int,
) -> c_int;
pub fn posix_spawn_file_actions_addclosefrom_np(
file_actions: *mut posix_spawn_file_actions_t,
lowfiledes: c_int,
) -> c_int;
pub fn posix_spawn_file_actions_addchdir(
file_actions: *mut posix_spawn_file_actions_t,
path: *const c_char,
) -> c_int;
pub fn posix_spawn_file_actions_addchdir_np(
file_actions: *mut posix_spawn_file_actions_t,
path: *const c_char,
) -> c_int;
pub fn posix_spawn_file_actions_addfchdir(
file_actions: *mut posix_spawn_file_actions_t,
fd: c_int,
) -> c_int;

pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int;
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: crate::pid_t) -> c_int;
pub fn posix_spawnattr_getpgroup(
attr: *const posix_spawnattr_t,
_pgroup: *mut crate::pid_t,
) -> c_int;
pub fn posix_spawnattr_setschedparam(
attr: *mut posix_spawnattr_t,
param: *const crate::sched_param,
) -> c_int;
pub fn posix_spawnattr_getschedparam(
attr: *const posix_spawnattr_t,
param: *mut crate::sched_param,
) -> c_int;
pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, policy: c_int) -> c_int;
pub fn posix_spawnattr_getschedpolicy(
attr: *const posix_spawnattr_t,
_policy: *mut c_int,
) -> c_int;
pub fn posix_spawnattr_setsigdefault(
attr: *mut posix_spawnattr_t,
sigdefault: *const sigset_t,
) -> c_int;
pub fn posix_spawnattr_getsigdefault(
attr: *const posix_spawnattr_t,
sigdefault: *mut sigset_t,
) -> c_int;
pub fn posix_spawnattr_setsigignore_np(
attr: *mut posix_spawnattr_t,
sigignore: *const sigset_t,
) -> c_int;
pub fn posix_spawnattr_getsigignore_np(
attr: *const posix_spawnattr_t,
sigignore: *mut sigset_t,
) -> c_int;
pub fn posix_spawnattr_setsigmask(
attr: *mut posix_spawnattr_t,
sigmask: *const sigset_t,
) -> c_int;
pub fn posix_spawnattr_getsigmask(
attr: *const posix_spawnattr_t,
sigmask: *mut sigset_t,
) -> c_int;

pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void;

pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/solarish/solaris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ pub const PRIV_TPD_UNSAFE: c_uint = 0x0800;
pub const PRIV_PROC_TPD_RESET: c_uint = 0x1000;
pub const PRIV_TPD_KILLABLE: c_uint = 0x2000;

pub const POSIX_SPAWN_SETSID: c_short = 0x400;

Comment on lines +192 to +193
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see a solaris.txt, and I wasn't sure whether a definition being in both solaris.rs and illumos.rs was enough to put it in solarish.txt.

pub const PRIV_USER: c_uint = PRIV_DEBUG
| PRIV_PROC_SENSITIVE
| NET_MAC_AWARE
Expand Down
Loading