mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
refactor: use scoped thread to avoid copy
This commit is contained in:
parent
d044164f26
commit
46c1aa62ce
1 changed files with 24 additions and 24 deletions
|
|
@ -263,14 +263,13 @@ pub fn get_error(shell: &str, command: &str) -> String {
|
||||||
pub fn error_output_threaded(shell: &str, command: &str) -> String {
|
pub fn error_output_threaded(shell: &str, command: &str) -> String {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
let _shell = shell.to_owned();
|
thread::scope(|s| {
|
||||||
let _command = command.to_owned();
|
s.spawn(|| {
|
||||||
thread::spawn(move || {
|
|
||||||
sender
|
sender
|
||||||
.send(
|
.send(
|
||||||
std::process::Command::new(_shell)
|
std::process::Command::new(shell)
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(_command)
|
.arg(command)
|
||||||
.env("LC_ALL", "C")
|
.env("LC_ALL", "C")
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process"),
|
.expect("failed to execute process"),
|
||||||
|
|
@ -289,6 +288,7 @@ pub fn error_output_threaded(shell: &str, command: &str) -> String {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command_output(shell: &str, command: &str) -> String {
|
pub fn command_output(shell: &str, command: &str) -> String {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue