Skip to content

Commit

Permalink
a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonkaliski committed Jan 24, 2024
1 parent f6e080c commit 33fc4cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ impl Pty {

let pid = child.id();

// We're creating a new thread for every child, this uses a bit more system resources compared
// to alternatives (below), trading off simplicity of implementation.
//
// The altneratives:
// - Mandate that every single `wait` goes through a central process-wide loop that knows
// about all processes (this is what `pid1` does), but needs a bit of care and some static
// analysis to ensure that every single call goes through the wrapper to avoid double `wait`'s
// on a child.
// - Have a single thread loop where other entities can register children (by sending the pid
// over a channel) and this loop can use `epoll` to listen for each child's `pidfd` for when
// they are ready to be `wait`'ed. This has the inconvenience that it consumes one FD per child.
//
// For discussion check out: https://github.com/replit/ruspty/pull/1#discussion_r1463672548
thread::spawn(move || match child.wait() {
Ok(status) => {
if status.success() {
Expand Down

0 comments on commit 33fc4cb

Please sign in to comment.