Skip to content

Commit 4238a8f

Browse files
committed
Add target attribute to create_pidfd field in Command
1 parent cfb2d72 commit 4238a8f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

library/std/src/sys/unix/process/process_common.rs

+24
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub struct Command {
7979
stdin: Option<Stdio>,
8080
stdout: Option<Stdio>,
8181
stderr: Option<Stdio>,
82+
#[cfg(target_os = "linux")]
8283
pub(crate) create_pidfd: bool,
8384
}
8485

@@ -125,6 +126,28 @@ pub enum Stdio {
125126
}
126127

127128
impl Command {
129+
#[cfg(not(target_os = "linux"))]
130+
pub fn new(program: &OsStr) -> Command {
131+
let mut saw_nul = false;
132+
let program = os2c(program, &mut saw_nul);
133+
Command {
134+
argv: Argv(vec![program.as_ptr(), ptr::null()]),
135+
args: vec![program.clone()],
136+
program,
137+
env: Default::default(),
138+
cwd: None,
139+
uid: None,
140+
gid: None,
141+
saw_nul,
142+
closures: Vec::new(),
143+
groups: None,
144+
stdin: None,
145+
stdout: None,
146+
stderr: None,
147+
}
148+
}
149+
150+
#[cfg(target_os = "linux")]
128151
pub fn new(program: &OsStr) -> Command {
129152
let mut saw_nul = false;
130153
let program = os2c(program, &mut saw_nul);
@@ -179,6 +202,7 @@ impl Command {
179202
self.groups = Some(Box::from(groups));
180203
}
181204

205+
#[cfg(target_os = "linux")]
182206
pub fn create_pidfd(&mut self, val: bool) {
183207
self.create_pidfd = val;
184208
}

0 commit comments

Comments
 (0)