From e9dd8f1a9bf41104e21236b996aa6e12d683bf58 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy <mmstickman@gmail.com> Date: Sun, 5 Nov 2017 16:18:20 -0500 Subject: [PATCH] Replace sys::getpid() w/ process::id() --- src/lib.rs | 1 + src/main.rs | 1 + src/shell/binary/prompt.rs | 3 ++- src/shell/mod.rs | 2 +- src/shell/pipe_exec/job_control.rs | 3 ++- src/shell/pipe_exec/mod.rs | 4 ++-- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 876457ac..b5d6c85a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ #![feature(conservative_impl_trait)] #![feature(integer_atomics)] #![feature(pointer_methods)] +#![feature(getpid)] extern crate app_dirs; #[macro_use] diff --git a/src/main.rs b/src/main.rs index 48327da4..f2767123 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ #![feature(conservative_impl_trait)] #![feature(integer_atomics)] #![feature(pointer_methods)] +#![feature(getpid)] // For a performance boost on Linux // #![feature(alloc_system)] diff --git a/src/shell/binary/prompt.rs b/src/shell/binary/prompt.rs index 54293de9..0e86f154 100644 --- a/src/shell/binary/prompt.rs +++ b/src/shell/binary/prompt.rs @@ -1,6 +1,7 @@ use super::super::{Function, Shell}; use parser::shell_expand::expand_string; use std::io::Read; +use std::process; use sys; pub(crate) fn prompt(shell: &mut Shell) -> String { @@ -41,6 +42,6 @@ pub(crate) fn prompt_fn(shell: &mut Shell) -> Option<String> { } // Ensure that the parent retains ownership of the terminal before exiting. - let _ = sys::tcsetpgrp(sys::STDIN_FILENO, sys::getpid().unwrap()); + let _ = sys::tcsetpgrp(sys::STDIN_FILENO, process::id()); output } diff --git a/src/shell/mod.rs b/src/shell/mod.rs index adda1d98..19b9b031 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -534,7 +534,7 @@ impl<'a> Expander for Shell { } // Ensure that the parent retains ownership of the terminal before exiting. - let _ = sys::tcsetpgrp(sys::STDIN_FILENO, sys::getpid().unwrap()); + let _ = sys::tcsetpgrp(sys::STDIN_FILENO, process::id()); output } } diff --git a/src/shell/pipe_exec/job_control.rs b/src/shell/pipe_exec/job_control.rs index 786f7ab5..6cd9952f 100644 --- a/src/shell/pipe_exec/job_control.rs +++ b/src/shell/pipe_exec/job_control.rs @@ -6,6 +6,7 @@ use std::fmt; use std::sync::{Arc, Mutex}; use std::thread::{sleep, spawn}; use std::time::Duration; +use std::process; use sys; use sys::job_control as self_sys; @@ -123,7 +124,7 @@ impl JobControl for Shell { } }; // Have the shell reclaim the TTY - set_foreground_as(sys::getpid().unwrap()); + set_foreground_as(process::id()); status } diff --git a/src/shell/pipe_exec/mod.rs b/src/shell/pipe_exec/mod.rs index 21946764..b4e40455 100644 --- a/src/shell/pipe_exec/mod.rs +++ b/src/shell/pipe_exec/mod.rs @@ -25,7 +25,7 @@ use std::iter; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::process::CommandExt; use std::path::Path; -use std::process::{exit, Command}; +use std::process::{self, exit, Command}; use sys; type RefinedItem = (RefinedJob, JobKind, Vec<Redirection>, Vec<Input>); @@ -427,7 +427,7 @@ impl PipelineExecution for Shell { let exit_status = pipe(self, piped_commands, foreground); // Set the shell as the foreground process again to regain the TTY. if foreground && !self.is_library { - let _ = sys::tcsetpgrp(0, sys::getpid().unwrap()); + let _ = sys::tcsetpgrp(0, process::id()); } exit_status } -- GitLab