Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eio_posix: initial support for subprocesses #461

Merged
merged 7 commits into from
Mar 20, 2023

Commits on Mar 15, 2023

  1. eio_posix: initial support for subprocesses

    To spawn a child executable on Unix, the parent `fork`s a copy of
    itself, then has the child copy set up the environment and `execve` the
    new program.
    
    However, we cannot run any OCaml code in the forked child process. This
    is because `fork` only duplicates its own domain. To the child, it
    appears that all other domains have stopped responding and if it tries
    to e.g. perform a GC then the child process will hang.
    
    Therefore, the `fork` and all child actions need to be written in C.
    To keep this flexible, this PR adds a new `fork_action` type and lets
    the user provide a list of such actions to perform.
    talex5 committed Mar 15, 2023
    Configuration menu
    Copy the full SHA
    0bec10c View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2023

  1. Use calloc for safety

    haesbaert authored and talex5 committed Mar 16, 2023
    Configuration menu
    Copy the full SHA
    fb97c16 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3e8f8d6 View commit details
    Browse the repository at this point in the history
  3. Move Eio_posix.Process inside Low_level

    Also, make `Process.t` abstract and document that `execve` can only go
    last.
    
    Suggested by Patrick Ferris.
    talex5 committed Mar 16, 2023
    Configuration menu
    Copy the full SHA
    56da38f View commit details
    Browse the repository at this point in the history

Commits on Mar 20, 2023

  1. Pass Rcfd to Fork_action.fchdir

    We can operate directly on the safe wrapper, which also simplifies the
    code a bit.
    
    Also, add a test for `fchdir`.
    talex5 committed Mar 20, 2023
    Configuration menu
    Copy the full SHA
    16ec359 View commit details
    Browse the repository at this point in the history
  2. Have fork actions call _exit directly on error

    This simplifies the code a bit.
    
    Also, check the type of the function passed to `Val_fork_fn`.
    talex5 committed Mar 20, 2023
    Configuration menu
    Copy the full SHA
    d10a720 View commit details
    Browse the repository at this point in the history
  3. Update some comments

    talex5 committed Mar 20, 2023
    Configuration menu
    Copy the full SHA
    970833b View commit details
    Browse the repository at this point in the history