Skip to content

Commit

Permalink
daemons: Log POSIX signal names alongside their numbers in handlers
Browse files Browse the repository at this point in the history
Closes #6225

Signed-off-by: Andrii Sultanov <[email protected]>
  • Loading branch information
last-genius committed Jan 14, 2025
1 parent f58d8d3 commit 3dfcbf6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions ocaml/networkd/bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
(libraries
astring
clock
fmt
forkexec
http_lib
integers
Expand Down
4 changes: 3 additions & 1 deletion ocaml/networkd/bin/network_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ let on_shutdown signal =
let dbg = "shutdown" in
Debug.with_thread_associated dbg
(fun () ->
debug "xcp-networkd caught signal %d; performing cleanup actions." signal ;
debug "xcp-networkd caught signal %s (%d); performing cleanup actions."
Fmt.(to_to_string Dump.signal signal)
signal ;
write_config ()
)
()
Expand Down
1 change: 1 addition & 0 deletions ocaml/xcp-rrdd/bin/rrdd/dune
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

ezxenstore.core
ezxenstore.watch
fmt
forkexec
http_lib
httpsvr
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xcp-rrdd/bin/rrdd/xcp_rrdd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ let configure_writers () =
(** we need to make sure we call exit on fatal signals to make sure profiling
data is dumped *)
let stop err writers signal =
debug "caught signal %d" signal ;
debug "caught signal %s (%d)" Fmt.(to_to_string Dump.signal signal) signal ;
List.iter (fun (_, writer) -> writer.Rrd_writer.cleanup ()) writers ;
exit err

Expand Down
5 changes: 4 additions & 1 deletion ocaml/xenopsd/lib/xenopsd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ let main backend =
in
(* we need to catch this to make sure at_exit handlers are triggered. In
particuar, triggers for the bisect_ppx coverage profiling *)
let signal_handler n = debug "caught signal %d" n ; exit 0 in
let signal_handler n =
debug "caught signal %s (%d)" Fmt.(to_to_string Dump.signal n) n ;
exit 0
in
Sys.set_signal Sys.sigpipe Sys.Signal_ignore ;
Sys.set_signal Sys.sigterm (Sys.Signal_handle signal_handler) ;
Xenops_utils.set_fs_backend
Expand Down

0 comments on commit 3dfcbf6

Please sign in to comment.