Ignore output of child processes
This commit is contained in:
parent
60731de5ef
commit
0b6c39a79c
1 changed files with 16 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
use std::{collections::HashMap, sync::Arc, option::Option, process::{Command, Stdio}};
|
use std::{collections::HashMap, sync::Arc, option::Option, process::{Command, Stdio}};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tokio_stream::StreamExt;
|
use tokio_stream::StreamExt;
|
||||||
use fork::{fork, setsid, Fork};
|
use fork::{fork, Fork};
|
||||||
use evdev::{EventStream, Key, RelativeAxisType, AbsoluteAxisType, EventType, InputEvent};
|
use evdev::{EventStream, Key, RelativeAxisType, AbsoluteAxisType, EventType, InputEvent};
|
||||||
use crate::virtual_devices::VirtualDevices;
|
use crate::virtual_devices::VirtualDevices;
|
||||||
use crate::Config;
|
use crate::Config;
|
||||||
|
@ -429,11 +429,21 @@ impl EventReader {
|
||||||
match &self.environment.sudo_user {
|
match &self.environment.sudo_user {
|
||||||
Ok(sudo_user) => {
|
Ok(sudo_user) => {
|
||||||
for command in command_list {
|
for command in command_list {
|
||||||
|
match fork() {
|
||||||
|
Ok(Fork::Child) => {
|
||||||
Command::new("sh")
|
Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(format!("env runuser {} -c {}", sudo_user.as_str(), command))
|
.arg(format!("env runuser {} -c {}", sudo_user.as_str(), command))
|
||||||
|
.stdin(Stdio::null())
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Failed to run command.");
|
.expect("Failed to run command.");
|
||||||
|
std::process::exit(0);
|
||||||
|
},
|
||||||
|
Ok(Fork::Parent(_)) => (),
|
||||||
|
Err(_) => std::process::exit(1),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -443,7 +453,6 @@ impl EventReader {
|
||||||
for command in command_list {
|
for command in command_list {
|
||||||
match fork() {
|
match fork() {
|
||||||
Ok(Fork::Child) => {
|
Ok(Fork::Child) => {
|
||||||
setsid().unwrap();
|
|
||||||
Command::new("sh")
|
Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(command)
|
.arg(command)
|
||||||
|
|
Loading…
Add table
Reference in a new issue