async-process/Cargo.toml

51 lines
1.4 KiB
TOML
Raw Normal View History

2020-08-18 20:19:25 +00:00
[package]
name = "async-process"
2021-04-24 08:45:31 +00:00
# When publishing a new version:
# - Update CHANGELOG.md
# - Create "v2.x.y" git tag
version = "2.2.2"
2020-08-18 20:19:25 +00:00
authors = ["Stjepan Glavina <stjepang@gmail.com>"]
2023-10-08 05:56:48 +00:00
edition = "2021"
2023-06-11 04:20:50 +00:00
rust-version = "1.63"
2020-08-19 13:34:03 +00:00
description = "Async interface for working with processes"
license = "Apache-2.0 OR MIT"
2020-12-26 14:47:13 +00:00
repository = "https://github.com/smol-rs/async-process"
2020-08-19 13:34:03 +00:00
keywords = ["process", "spawn", "command", "subprocess", "child"]
categories = ["asynchronous", "os"]
2022-01-08 13:03:15 +00:00
exclude = ["/.*"]
2020-08-18 20:19:25 +00:00
[dependencies]
async-lock = "3.0.0"
cfg-if = "1.0"
event-listener = "5.1.0"
futures-lite = "2.0.0"
tracing = { version = "0.1.40", default-features = false }
2020-08-18 20:19:25 +00:00
[target.'cfg(unix)'.dependencies]
async-io = "2.1.0"
async-signal = "0.2.3"
rustix = { version = "0.38", default-features = false, features = ["std", "fs"] }
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
async-channel = "2.0.0"
async-task = "4.7.0"
[target.'cfg(all(unix, not(any(target_os = "linux", target_os = "android"))))'.dependencies]
rustix = { version = "0.38", default-features = false, features = ["std", "fs", "process"] }
2020-08-18 20:19:25 +00:00
[target.'cfg(windows)'.dependencies]
async-channel = "2.0.0"
2020-09-07 13:59:51 +00:00
blocking = "1.0.0"
2020-08-18 20:19:25 +00:00
2022-11-27 05:14:01 +00:00
[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.52"
2020-08-19 13:34:03 +00:00
default-features = false
2020-08-18 20:19:25 +00:00
features = [
2022-11-27 05:14:01 +00:00
"Win32_Foundation",
"Win32_System_Threading",
2022-11-27 07:22:13 +00:00
]
[dev-dependencies]
feat: Add a way to run without the async-process thread I know I said that I wouldn't add any more features, but I think this is important enough. Right now, a thread called "async-process" is responsible for listening for SIGCHLD and reaping zombie processes. This listens for the SIGCHLD signal in Unix and uses a channel connected to the waitable handle on Windows. While this works, we can do better. Through async-signal, the signal was already asynchronous on Unix; we were already just using async_io::block_on to wait on the signal. After swapping out the channel used on Windows with async-channel, the process reaping function "reap" can be reimplemented as a fully asynchronous future. From here we must make sure this future is being polled at all times. To facilitate this, a function named "driver()" is added to the public API. This future acquires a lock on the reaper structure and calls the "reap()" future indefinitely. Multiple drivers can be created at once; they will just wait forever on this lock. This future is intended to be spawned onto an executor and left to run forever, making sure all child processes are signalled whenever necessary. If no tasks are running the driver future, the "async-process" thread is spawned and runs the "reap()" future itself. I've added the following controls to make sure that this system is robust: - If a "driver" task is dropped, another "driver" task will acquire the lock and keep the reaper active. - Before being dropped, the task checks to see if it is the last driver. If it is, it will spawn the "async-process" thread to be the driver. - When a Child is being created, it checks if there are any active drivers. If there are none, it spawns the "async-process" thread itself. - One concern is that the driver future wil try to spawn the "async-process" thread as the application exits and the task is being dropped, which will be unnecessary and lead to slower shutdowns. To prevent this, the future checks to see if there are any extant `Child` instances (a new refcount is added to Reaper to facilitate this). If there are none, and if there are no zombie processes, it does not spawn the additional thread. - Someone can still `mem::forget()` the driver thread. This does not lead to undefined behavior and just leads to processes being left dangling. At this point they're asking for wacky behavior. This strategy might also be viable for `async-io`, if we want to try to avoid needing to spawn the additional thread there as well. Closes #7 cc smol-rs/async-io#40 Signed-off-by: John Nunley <dev@notgull.net>
2023-10-11 00:47:46 +00:00
async-executor = "1.5.1"
async-io = "2.1.0"