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

Lwt not handling Ctrl+C correctly when running in Docker #1027

Open
maxRN opened this issue Aug 22, 2024 · 1 comment
Open

Lwt not handling Ctrl+C correctly when running in Docker #1027

maxRN opened this issue Aug 22, 2024 · 1 comment

Comments

@maxRN
Copy link

maxRN commented Aug 22, 2024

The SIGINT (Ctrl+C) signal isn't handled properly when running inside a Docker container.

I would expect when pressing Ctrl+C that the program and then the container exits. Instead, nothing happens and after pressing Ctrl+C three times the container is stopped forcefully (but still running in the background, needs to be killed manually with docker kill)

Reproduction example at https://github.com/maxrn/lwt_test including Docker file, but this is the code I used:

let httpaf_connection_handler sock_addr y =
  let _ = sock_addr in
  let _ = y in
  let%lwt () = Lwt_io.printl "got request!" in
  Lwt_io.eprintl "got request on stderr!"

let x =
  let%lwt listen_address =
    let%lwt addresses = Lwt_unix.getaddrinfo "127.0.0.1" "7654" [] in
    match addresses with
    | [] -> failwith "shouldn't happen"
    | address :: _ -> Lwt.return Lwt_unix.(address.ai_addr)
  in
  let%lwt server =
    Lwt_io.establish_server_with_client_socket listen_address
      httpaf_connection_handler
  in
  let never = fst (Lwt.wait ()) in
  let stop = never in
  let%lwt () = stop in
  Lwt_io.shutdown_server server

let () = Lwt_main.run x

I'm not sure if that's really the most minimal working example, but it's the best I could come up with. It's mostly cobbled together from how Dream uses Lwt internally (where we first encountered the bug)

fyi @aantron

@maxRN
Copy link
Author

maxRN commented Aug 22, 2024

Might be related to #1012?

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