Fork in a Lwt framework

I plan to execute a command in a subprocess from a Lwt Framework (Dream).

I guess, all Unix syscall (fork, pipe…) from the current (father) process should be done from Lwt_unix module, and the Unix syscall from the child process should be done directly from Unix (and avoid scheduling some Lwt promise twice).

Some advices ?

The alternative would be everything in the Unix syscall. Output writes in the pipe would block the whole framework, but in my case, that wouldn’t be long.

1 Like

See the documentation of Lwt_unix.fork, the options and recommendations are explained there.

Note though that Lwt_unix.fork isn’t safe for the reasons mentioned here. New processes and Lwt don’t work well together. Unix.create_process* is OK though.

2 Likes

I guess that Unix.open_process_args_out would be OK