Skip to content

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

Description

@joehendrix

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for comments

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions