Skip to content

Commit

Permalink
Take some of sys/vxworks/process/* from sys/unix instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Oct 16, 2020
1 parent 408db0d commit 0f0257b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 407 deletions.
24 changes: 20 additions & 4 deletions library/std/src/sys/unix/ext/process.rs
Expand Up @@ -16,12 +16,20 @@ pub trait CommandExt {
/// `setuid` call in the child process. Failure in the `setuid`
/// call will cause the spawn to fail.
#[stable(feature = "rust1", since = "1.0.0")]
fn uid(&mut self, id: u32) -> &mut process::Command;
fn uid(
&mut self,
#[cfg(not(target_os = "vxworks"))] id: u32,
#[cfg(target_os = "vxworks")] id: u16,
) -> &mut process::Command;

/// Similar to `uid`, but sets the group ID of the child process. This has
/// the same semantics as the `uid` field.
#[stable(feature = "rust1", since = "1.0.0")]
fn gid(&mut self, id: u32) -> &mut process::Command;
fn gid(
&mut self,
#[cfg(not(target_os = "vxworks"))] id: u32,
#[cfg(target_os = "vxworks")] id: u16,
) -> &mut process::Command;

/// Schedules a closure to be run just before the `exec` function is
/// invoked.
Expand Down Expand Up @@ -115,12 +123,20 @@ pub trait CommandExt {

#[stable(feature = "rust1", since = "1.0.0")]
impl CommandExt for process::Command {
fn uid(&mut self, id: u32) -> &mut process::Command {
fn uid(
&mut self,
#[cfg(not(target_os = "vxworks"))] id: u32,
#[cfg(target_os = "vxworks")] id: u16,
) -> &mut process::Command {
self.as_inner_mut().uid(id);
self
}

fn gid(&mut self, id: u32) -> &mut process::Command {
fn gid(
&mut self,
#[cfg(not(target_os = "vxworks"))] id: u32,
#[cfg(target_os = "vxworks")] id: u16,
) -> &mut process::Command {
self.as_inner_mut().gid(id);
self
}
Expand Down
4 changes: 3 additions & 1 deletion library/std/src/sys/unix/process/process_common.rs
Expand Up @@ -24,6 +24,8 @@ cfg_if::cfg_if! {
// fuchsia doesn't have /dev/null
} else if #[cfg(target_os = "redox")] {
const DEV_NULL: &str = "null:\0";
} else if #[cfg(target_os = "vxworks")] {
const DEV_NULL: &str = "/null\0";
} else {
const DEV_NULL: &str = "/dev/null\0";
}
Expand All @@ -48,7 +50,7 @@ cfg_if::cfg_if! {
raw[bit / 8] |= 1 << (bit % 8);
return 0;
}
} else {
} else if #[cfg(not(target_os = "vxworks"))] {
pub use libc::{sigemptyset, sigaddset};
}
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/unix/process/process_unix.rs
Expand Up @@ -6,6 +6,10 @@ use crate::sys;
use crate::sys::cvt;
use crate::sys::process::process_common::*;

#[cfg(target_os = "vxworks")]
use libc::RTP_ID as pid_t;

#[cfg(not(target_os = "vxworks"))]
use libc::{c_int, gid_t, pid_t, uid_t};

////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 4 additions & 2 deletions library/std/src/sys/vxworks/process/mod.rs
@@ -1,7 +1,9 @@
pub use self::process_common::{Command, ExitCode, ExitStatus, Stdio, StdioPipes};
pub use self::process_inner::Process;
pub use self::process_common::{Command, CommandArgs, ExitCode, Stdio, StdioPipes};
pub use self::process_inner::{ExitStatus, Process};
pub use crate::ffi::OsString as EnvKey;
pub use crate::sys_common::process::CommandEnvs;

#[path = "../../unix/process/process_common.rs"]
mod process_common;
#[path = "process_vxworks.rs"]
mod process_inner;

0 comments on commit 0f0257b

Please sign in to comment.