Skip to content

Commit 92d50c9

Browse files
committed
Add posix_spawn bindings for FreeBSD
1 parent 88c33d4 commit 92d50c9

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ fn main() {
294294
cfg.header("sys/shm.h");
295295
cfg.header("sys/procdesc.h");
296296
cfg.header("sys/rtprio.h");
297+
cfg.header("spawn.h");
297298
}
298299

299300
if netbsd {

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ pub type key_t = ::c_long;
1515
pub type msglen_t = ::c_ulong;
1616
pub type msgqnum_t = ::c_ulong;
1717

18+
pub type posix_spawnattr_t = *mut ::c_void;
19+
pub type posix_spawn_file_actions_t = *mut ::c_void;
20+
1821
s! {
1922
pub struct utmpx {
2023
pub ut_type: ::c_short,
@@ -851,6 +854,13 @@ pub const RTP_PRIO_REALTIME: ::c_ushort = 2;
851854
pub const RTP_PRIO_NORMAL: ::c_ushort = 3;
852855
pub const RTP_PRIO_IDLE: ::c_ushort = 4;
853856

857+
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
858+
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
859+
pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04;
860+
pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08;
861+
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10;
862+
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20;
863+
854864
extern {
855865
pub fn __error() -> *mut ::c_int;
856866

@@ -913,6 +923,72 @@ extern {
913923

914924
pub fn rtprio_thread(function: ::c_int, lwpid: ::lwpid_t,
915925
rtp: *mut super::rtprio) -> ::c_int;
926+
927+
pub fn posix_spawn(pid: *mut ::pid_t,
928+
path: *const ::c_char,
929+
file_actions: *const ::posix_spawn_file_actions_t,
930+
attrp: *const ::posix_spawnattr_t,
931+
argv: *const *mut ::c_char,
932+
envp: *const *mut ::c_char) -> ::c_int;
933+
pub fn posix_spawnp(pid: *mut ::pid_t,
934+
file: *const ::c_char,
935+
file_actions: *const ::posix_spawn_file_actions_t,
936+
attrp: *const ::posix_spawnattr_t,
937+
argv: *const *mut ::c_char,
938+
envp: *const *mut ::c_char) -> ::c_int;
939+
pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int;
940+
pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int;
941+
pub fn posix_spawnattr_getsigdefault(attr: *const posix_spawnattr_t,
942+
default: *mut ::sigset_t) -> ::c_int;
943+
pub fn posix_spawnattr_setsigdefault(attr: *mut posix_spawnattr_t,
944+
default: *const ::sigset_t) -> ::c_int;
945+
pub fn posix_spawnattr_getsigmask(attr: *const posix_spawnattr_t,
946+
default: *mut ::sigset_t) -> ::c_int;
947+
pub fn posix_spawnattr_setsigmask(attr: *mut posix_spawnattr_t,
948+
default: *const ::sigset_t) -> ::c_int;
949+
pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t,
950+
flags: *mut ::c_short) -> ::c_int;
951+
pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t,
952+
flags: ::c_short) -> ::c_int;
953+
pub fn posix_spawnattr_getpgroup(attr: *const posix_spawnattr_t,
954+
flags: *mut ::pid_t) -> ::c_int;
955+
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t,
956+
flags: ::pid_t) -> ::c_int;
957+
pub fn posix_spawnattr_getschedpolicy(attr: *const posix_spawnattr_t,
958+
flags: *mut ::c_int) -> ::c_int;
959+
pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t,
960+
flags: ::c_int) -> ::c_int;
961+
pub fn posix_spawnattr_getschedparam(
962+
attr: *const posix_spawnattr_t,
963+
param: *mut ::sched_param,
964+
) -> ::c_int;
965+
pub fn posix_spawnattr_setschedparam(
966+
attr: *mut posix_spawnattr_t,
967+
param: *const ::sched_param,
968+
) -> ::c_int;
969+
970+
pub fn posix_spawn_file_actions_init(
971+
actions: *mut posix_spawn_file_actions_t,
972+
) -> ::c_int;
973+
pub fn posix_spawn_file_actions_destroy(
974+
actions: *mut posix_spawn_file_actions_t,
975+
) -> ::c_int;
976+
pub fn posix_spawn_file_actions_addopen(
977+
actions: *mut posix_spawn_file_actions_t,
978+
fd: ::c_int,
979+
path: *const ::c_char,
980+
oflag: ::c_int,
981+
mode: ::mode_t,
982+
) -> ::c_int;
983+
pub fn posix_spawn_file_actions_addclose(
984+
actions: *mut posix_spawn_file_actions_t,
985+
fd: ::c_int,
986+
) -> ::c_int;
987+
pub fn posix_spawn_file_actions_adddup2(
988+
actions: *mut posix_spawn_file_actions_t,
989+
fd: ::c_int,
990+
newfd: ::c_int,
991+
) -> ::c_int;
916992
}
917993

918994
cfg_if! {

0 commit comments

Comments
 (0)