attach pid to child stdio and pidfd types
This commit is contained in:
parent
c60a145587
commit
da0500d1f9
2 changed files with 10 additions and 10 deletions
|
|
@ -336,8 +336,8 @@ impl Daemon {
|
|||
fn proxy_stdio(&mut self, fd: &BorrowedFd) -> Result<(), IoError> {
|
||||
let info = self.fd_info.get(&fd.as_raw_fd()).unwrap();
|
||||
let label = match info.kind {
|
||||
FdKind::ChildStdout => "stdout",
|
||||
FdKind::ChildStderr => "stderr",
|
||||
FdKind::ChildStdout(pid) => format!("stdout[{pid}]"),
|
||||
FdKind::ChildStderr(pid) => format!("stderr[{pid}]"),
|
||||
other => unreachable!("child stdio cannot have kind {other:?}"),
|
||||
};
|
||||
// FIXME: don't use a new allocation every time.
|
||||
|
|
@ -456,8 +456,8 @@ impl Daemon {
|
|||
unreachable!("`child` is given `.stderr(Stdio::piped())`");
|
||||
});
|
||||
|
||||
let _token = self.register(stdout.into_raw_fd(), FdKind::ChildStdout);
|
||||
let _token = self.register(stderr.into_raw_fd(), FdKind::ChildStderr);
|
||||
let _token = self.register(stdout.into_raw_fd(), FdKind::ChildStdout(pid));
|
||||
let _token = self.register(stderr.into_raw_fd(), FdKind::ChildStderr(pid));
|
||||
|
||||
match rustix::process::pidfd_open(pid, PidfdFlags::NONBLOCK) {
|
||||
Ok(pidfd) => {
|
||||
|
|
@ -668,14 +668,14 @@ impl Daemon {
|
|||
}
|
||||
}
|
||||
},
|
||||
FdKind::ChildStdout => {
|
||||
FdKind::ChildStdout(_pid) => {
|
||||
warn!("got stdout");
|
||||
// SAFETY: oh boy.
|
||||
let stdout = unsafe { BorrowedFd::borrow_raw(fd) };
|
||||
self.proxy_stdio(&stdout)
|
||||
.unwrap_or_else(|e| error!("failed to proxy child stdout: {e}"));
|
||||
},
|
||||
FdKind::ChildStderr => {
|
||||
FdKind::ChildStderr(_pid) => {
|
||||
warn!("got stderr");
|
||||
// SAFETY: oh boy.
|
||||
let stderr = unsafe { BorrowedFd::borrow_raw(fd) };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue