leanprover / leanprover/lean4

RFC: Async/interuptable additions to support running child processes with timeouts

Open
#14,438 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-medium RFC
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:

  1. Cancelable stream reads -- promise/Selector-based read via uv_pipe_open analogous to TCP reads.
  2. Async child stdio -- child stdout/stderr as cancelable UV pipes (uses 1).
  3. Event-based spawn/wait — uv_spawn with uv_exit callback; uv_process_kill and uv_kill for 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.