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

Log proper names for POSIX signals #6228

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

psafont
Copy link
Member

@psafont psafont commented Jan 14, 2025

The integer values that OCaml uses for signals should never be printed as integers. They can cause confusion because they don't match the C POSIX values.

Change the unixext function that converts them to string to stop building a list and finding a value in the list to instead use pattern-matching. Also added some more values that got introduced in OCaml 4.03, and return a more compact value for unknown signals, following the same format as Fmt.Dump.signal.

Typically, engineers see signal -11 and assume it's SIGSEGV, when it's SIGTERM.

Fixes #6225

@psafont psafont force-pushed the private/paus/logsig branch from d32a9fb to c16e2cb Compare January 14, 2025 16:20
@psafont psafont force-pushed the private/paus/logsig branch 2 times, most recently from ca71749 to 7cca110 Compare January 14, 2025 16:56
@psafont psafont force-pushed the private/paus/logsig branch from 7cca110 to 4580f04 Compare January 14, 2025 17:00
Copy link
Contributor

@Vincent-lau Vincent-lau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the string_of_signal is unused after the second commit, or is it? Planning to squash it?

@psafont
Copy link
Member Author

psafont commented Jan 15, 2025

So the string_of_signal is unused after the second commit, or is it? Planning to squash it?

Yes, it's completely deleted by the second commit. I'm not planning on squashing it

The integer values that OCaml uses for signals should never be printed as they
are. They can cause confusion because they don't match the C POSIX values.

Change the unixext function that converts them to string to stop building a
list and finding a value in the list to instead use pattern-matching. Also
added some more values that got introduced in OCaml 4.03, and return a more
compact value for unknown signals, following the same format as Fmt.Dump.signal

Signed-off-by: Pau Ruiz Safont <[email protected]>
When signals are are written to logs, the POSIX name should be used to minimize
confusion. It makes sense that the function that does this is in the logging
library instead of the unix one, as most users will be already be using the
logging library, but not all the unix one.

Moving it there also allows for a more ergonomic usage with the logging
functions.

Signed-off-by: Pau Ruiz Safont <[email protected]>
@psafont psafont force-pushed the private/paus/logsig branch from 4580f04 to c0fbb69 Compare January 16, 2025 10:24
@@ -353,4 +353,8 @@ functor
with e -> log_backtrace_internal ~level:Syslog.Debug ~msg:"debug" e ()
end

module Pp = struct let mtime_span () = Fmt.str "%a" Mtime.Span.pp end
module Pp = struct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have liked PP or Pretty better - but it already exists.

@lindig
Copy link
Contributor

lindig commented Jan 16, 2025

Can we merge this?

@psafont psafont added this pull request to the merge queue Jan 16, 2025
Merged via the queue into xapi-project:master with commit 6c1e7ea Jan 16, 2025
15 checks passed
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

Successfully merging this pull request may close these issues.

daemons expose internal signal number in failure log
6 participants