RFC: Async/interuptable additions to support running child processes with timeouts
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Proposal
Running a child process with a timeout isn't safely implementable in pure Lean today. You can arm a cancelable timer, but Child.wait has a blocking call to waitpid.
Additionally, IO.FS.Handle.read is a blocking, uninterruptible fread. So a task in read canot be canceled in Lean. Note that if the child process exits, stdout/stderr will not be closed if either was passed to a still running grandchild process. Closing the Lean read end doesn't help.
Here's what I'd like:
- Cancelable stream reads -- promise/Selector-based read via
uv_pipe_openanalogous to TCP reads. - Async child stdio -- child stdout/stderr as cancelable UV pipes (uses 1).
- Event-based spawn/wait — uv_spawn with uv_exit callback;
uv_process_killanduv_killfor process-group kill.
This would build upon existing LibUV code.
Community Feedback
Ideas should be discussed on the Lean Zulip prior to submitting a proposal. Summarize all prior discussions and link them here.
Impact
Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing LibUV code and the current behavior of Child.wait and IO.FS.Handle.read. Trace how uv_pipe_open, uv_spawn, uv_exit, and process-kill operations are represented, then compare them with the three requested capabilities. Done means the proposal's cancelable reads, async child stdio, and event-based spawn/wait support are specified and implemented with appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100