Skip to content

Commit 58c1352

Browse files
committed
Add method to get create_pidfd value
1 parent 4238a8f commit 58c1352

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub struct Command {
8080
stdout: Option<Stdio>,
8181
stderr: Option<Stdio>,
8282
#[cfg(target_os = "linux")]
83-
pub(crate) create_pidfd: bool,
83+
create_pidfd: bool,
8484
}
8585

8686
// Create a new type for argv, so that we can make it `Send` and `Sync`
@@ -207,6 +207,17 @@ impl Command {
207207
self.create_pidfd = val;
208208
}
209209

210+
#[cfg(not(target_os = "linux"))]
211+
#[allow(dead_code)]
212+
pub fn get_create_pidfd(&self) -> bool {
213+
false
214+
}
215+
216+
#[cfg(target_os = "linux")]
217+
pub fn get_create_pidfd(&self) -> bool {
218+
self.create_pidfd
219+
}
220+
210221
pub fn saw_nul(&self) -> bool {
211222
self.saw_nul
212223
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Command {
162162
// we will fall through this block to a call to `fork()`
163163
if HAS_CLONE3.load(Ordering::Relaxed) {
164164
let mut flags = 0;
165-
if self.create_pidfd {
165+
if self.get_create_pidfd() {
166166
flags |= CLONE_PIDFD;
167167
}
168168

@@ -387,7 +387,7 @@ impl Command {
387387
|| (self.env_saw_path() && !self.program_is_path())
388388
|| !self.get_closures().is_empty()
389389
|| self.get_groups().is_some()
390-
|| self.create_pidfd
390+
|| self.get_create_pidfd()
391391
{
392392
return Ok(None);
393393
}

0 commit comments

Comments
 (0)