]> git.proxmox.com Git - rustc.git/blob - src/vendor/shared_child/README.md
New upstream version 1.23.0+dfsg1
[rustc.git] / src / vendor / shared_child / README.md
1 # shared_child.rs [![Travis build](https://travis-ci.org/oconnor663/shared_child.rs.svg?branch=master)](https://travis-ci.org/oconnor663/shared_child.rs) [![Build status](https://ci.appveyor.com/api/projects/status/900ckow3c5awq3t5/branch/master?svg=true)](https://ci.appveyor.com/project/oconnor663/shared-child-rs/branch/master) [![crates.io](https://img.shields.io/crates/v/shared_child.svg)](https://crates.io/crates/shared_child) [![docs.rs](https://docs.rs/shared_child/badge.svg)](https://docs.rs/shared_child)
2
3 A library for awaiting and killing child processes from multiple threads.
4
5 The
6 [`std::process::Child`](https://doc.rust-lang.org/std/process/struct.Child.html)
7 type in the standard library provides
8 [`wait`](https://doc.rust-lang.org/std/process/struct.Child.html#method.wait)
9 and
10 [`kill`](https://doc.rust-lang.org/std/process/struct.Child.html#method.kill)
11 methods that take `&mut self`, making it impossible to kill a child process
12 while another thread is waiting on it. That design works around a race
13 condition in Unix's `waitpid` function, where a PID might get reused as soon
14 as the wait returns, so a signal sent around the same time could
15 accidentally get delivered to the wrong process.
16
17 However with the newer POSIX `waitid` function, we can wait on a child
18 without freeing its PID for reuse. That makes it safe to send signals
19 concurrently. Windows has actually always supported this, by preventing PID
20 reuse while there are still open handles to a child process. This library
21 wraps `std::process::Child` for concurrent use, backed by these APIs.
22
23 - [Docs](https://docs.rs/shared_child)
24 - [Crate](https://crates.io/crates/shared_child)
25 - [Repo](https://github.com/oconnor663/shared_child.rs)