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

Child process of dune exec -w is not terminated on signal #11089

Open
MoritzHamann opened this issue Nov 3, 2024 · 0 comments
Open

Child process of dune exec -w is not terminated on signal #11089

MoritzHamann opened this issue Nov 3, 2024 · 0 comments

Comments

@MoritzHamann
Copy link

Expected Behavior

When running dune exec in watch mode (via dune exec -w <target>) and the target is an infinite process (e.g. a web server), a shutdown via signal (e.g. SIGINT) to the dune process should also forward the signal to the child process (<target>).

To be fair, this may be working as designed but I still wanted to raise this issue in case it's not.

Actual Behavior

Currently the signal terminates dune itself, leaving the target process orphaned.

Background

I've come across this issue as part of a dune integration into neovim. The editor plugin is doing some housekeeping and tracks all dune processes spawned during editing. Once they are not needed anymore the plugin stops those instances by sending SIGINT to the dune process leaving any running target process orphaned (as described above).

It would be great if dune could handle the cleanup of spawned child processes, otherwise I will need to fine some workaround with process groups, which are not very well supported in neovim 🫤 .

Reproduction

  1. Create a dune project with a target that will not shut down by itself. E.g. a simple Dream service with bin/main.ml
let () =
    Dream.run ~port:8080
    @@ Dream.router [ Dream.get "/" (fun _ -> Dream.html "Hello World")]
  1. run the server via dune exec -w bin/main.exe
  2. send SIGINT via kill -2 <dune_pid> to stop the dune process

Specifications

  • Version of dune (output of dune --version): 3.16.0
  • Version of ocaml (output of ocamlc --version): 5.2.0
  • Operating system (distribution and version): MacOS 14.6.1

Additional information

dune with the --verbose flag:

Shared cache: disabled
Shared cache location: /Users/moe/.cache/dune/db
Workspace root: /Users/moe/Projects/ocaml/myproject
Auto-detected concurrency: 8
Dune context:
 { name = "default"
 ; kind = "default"
 ; profile = Dev
 ; merlin = true
 ; fdo_target_exe = None
 ; build_dir = In_build_dir "default"
 ; instrument_with = []
 }
Success, waiting for filesystem changes...03.11.24 21:22:46.333                       Running at http://localhost:8080
03.11.24 21:22:46.333                       Type Ctrl+C to stop
Got signal INT, exiting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant