| Crates.io | mio-pidfd |
| lib.rs | mio-pidfd |
| version | 0.4.0 |
| created_at | 2019-09-23 10:16:53.016957+00 |
| updated_at | 2024-10-25 11:30:07.415084+00 |
| description | mio support for Linux's pidfd |
| homepage | |
| repository | https://github.com/samuelbrian/mio-pidfd |
| max_upload_size | |
| id | 166946 |
| size | 16,501 |
A Linux pidfd wrapper for mio. This is useful for using mio to wait for multiple child processes to exit in a non-blocking event-driven way.
Heavily inspired by mio-timerfd
use mio_pidfd::PidFd;
use mio::{Poll, Events, Token, Ready, PollOpt};
use std::process::{Command, Child};
let poll = Poll::new().unwrap();
let mut events = Events::with_capacity(1024);
let mut child = Command::new("/bin/sleep").arg("1").spawn().unwrap();
let pidfd = PidFd::new(&child).unwrap();
poll.register(&pidfd, Token(0), Ready::readable(), PollOpt::edge())
.unwrap();
poll.poll(&mut events, None).unwrap();
assert!(child.try_wait().unwrap().unwrap().code().unwrap() == 0);
This library relies on the pidfd_open() system call which was introduced
in Linux kernel version 5.3.
The pidfd_send_signal() system call (used by supplementary kill()
functionality) was introduced in Linux kernel version 5.1