1
0
Fork 0
forked from wry/wry

config: allow attaching file descriptors to commands

This commit is contained in:
Julian Orth 2024-03-06 19:44:43 +01:00
parent a1ba476e68
commit 2037a37c1e
8 changed files with 96 additions and 29 deletions

View file

@ -28,6 +28,7 @@ use {
future::Future,
mem,
ops::Deref,
os::fd::IntoRawFd,
panic::{catch_unwind, AssertUnwindSafe},
pin::Pin,
ptr,
@ -264,11 +265,26 @@ impl Client {
.iter()
.map(|(a, b)| (a.to_string(), b.to_string()))
.collect();
self.send(&ClientMessage::Run {
prog: &command.prog,
args: command.args.clone(),
env,
});
let fds: Vec<_> = command
.fds
.borrow_mut()
.drain()
.map(|(a, b)| (a, b.into_raw_fd()))
.collect();
if fds.is_empty() {
self.send(&ClientMessage::Run {
prog: &command.prog,
args: command.args.clone(),
env,
});
} else {
self.send(&ClientMessage::Run2 {
prog: &command.prog,
args: command.args.clone(),
env,
fds,
});
}
}
pub fn grab(&self, kb: InputDevice, grab: bool) {

View file

@ -375,6 +375,12 @@ pub enum ClientMessage<'a> {
pollable: PollableId,
writable: bool,
},
Run2 {
prog: &'a str,
args: Vec<String>,
env: Vec<(String, String)>,
fds: Vec<(i32, i32)>,
},
}
#[derive(Serialize, Deserialize, Debug)]