/// let cmd = Command::new("echo");
/// assert_eq!(cmd.get_program(), "echo");
/// ```
+ #[must_use]
#[stable(feature = "command_access", since = "1.57.0")]
pub fn get_program(&self) -> &OsStr {
self.inner.get_program()
/// cmd.current_dir("/bin");
/// assert_eq!(cmd.get_current_dir(), Some(Path::new("/bin")));
/// ```
+ #[must_use]
#[stable(feature = "command_access", since = "1.57.0")]
pub fn get_current_dir(&self) -> Option<&Path> {
self.inner.get_current_dir()
///
/// This struct is created by [`Command::get_args`]. See its documentation for
/// more.
+#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "command_access", since = "1.57.0")]
#[derive(Debug)]
pub struct CommandArgs<'a> {
/// its entire stdin before writing more than a pipe buffer's worth of output.
/// The size of a pipe buffer varies on different targets.
///
+ #[must_use]
#[stable(feature = "process", since = "1.0.0")]
pub fn piped() -> Stdio {
Stdio(imp::Stdio::MakePipe)
/// print!("You piped in the reverse of: ");
/// io::stdout().write_all(&output.stdout).unwrap();
/// ```
+ #[must_use]
#[stable(feature = "process", since = "1.0.0")]
pub fn inherit() -> Stdio {
Stdio(imp::Stdio::Inherit)
/// assert_eq!(String::from_utf8_lossy(&output.stdout), "");
/// // Ignores any piped-in input
/// ```
+ #[must_use]
#[stable(feature = "process", since = "1.0.0")]
pub fn null() -> Stdio {
Stdio(imp::Stdio::Null)
///
/// [`status`]: Command::status
/// [`wait`]: Child::wait
+//
+// We speak slightly loosely (here and in various other places in the stdlib docs) about `exit`
+// vs `_exit`. Naming of Unix system calls is not standardised across Unices, so terminology is a
+// matter of convention and tradition. For clarity we usually speak of `exit`, even when we might
+// mean an underlying system call such as `_exit`.
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[stable(feature = "process", since = "1.0.0")]
pub struct ExitStatus(imp::ExitStatus);
/// println!("failed to create 'projects/' directory: {}", status);
/// }
/// ```
+ #[must_use]
#[stable(feature = "process", since = "1.0.0")]
pub fn success(&self) -> bool {
self.0.exit_ok().is_ok()
/// None => println!("Process terminated by signal")
/// }
/// ```
+ #[must_use]
#[stable(feature = "process", since = "1.0.0")]
pub fn code(&self) -> Option<i32> {
self.0.code()
/// assert_eq!(bad.code(), Some(1));
/// # } // #[cfg(unix)]
/// ```
+ #[must_use]
pub fn code(&self) -> Option<i32> {
self.code_nonzero().map(Into::into)
}
/// assert_eq!(bad.code_nonzero().unwrap(), NonZeroI32::try_from(1).unwrap());
/// # } // cfg!(unix)
/// ```
+ #[must_use]
pub fn code_nonzero(&self) -> Option<NonZeroI32> {
self.0.code()
}
/// Converts an `ExitStatusError` (back) to an `ExitStatus`.
+ #[must_use]
pub fn into_status(&self) -> ExitStatus {
ExitStatus(self.0.into())
}
/// println!("ls command didn't start");
/// }
/// ```
+ #[must_use]
#[stable(feature = "process_id", since = "1.3.0")]
pub fn id(&self) -> u32 {
self.handle.id()
/// ```
///
///
+#[must_use]
#[stable(feature = "getpid", since = "1.26.0")]
pub fn id() -> u32 {
crate::sys::os::getpid()