[pacman-dev] [PATCH] alpm: log errors for scriptlets terminated by a signal
Fixes FS#36618. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- We *could* print the signal name here as well, but signal value-to-name can actually vary by architecture so it's not clear that it's something we necessarily want to get into.... lib/libalpm/util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index f1f760a..4b708ff 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -599,6 +599,10 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) _alpm_log(handle, ALPM_LOG_ERROR, _("command failed to execute correctly\n")); retval = 1; } + } else if(WIFSIGNALED(status) != 0) { + _alpm_log(handle, ALPM_LOG_ERROR, _("command terminated by signal %d\n"), + WTERMSIG(status)); + retval = 1; } } -- 1.8.3.4
On Tue, Aug 20, 2013 at 2:03 PM, Dave Reisner <dreisner@archlinux.org>wrote:
Fixes FS#36618.
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- We *could* print the signal name here as well, but signal value-to-name can actually vary by architecture so it's not clear that it's something we necessarily want to get into....
These would be documented in signal(7) on most platforms, and likely signal(3) on others, right? I doubt it makes sense to point there, but I do see strsignal() which appears to be reasonably portable: CONFORMING TO POSIX.1-2008. Present on Solaris and the BSDs.
lib/libalpm/util.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index f1f760a..4b708ff 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -599,6 +599,10 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) _alpm_log(handle, ALPM_LOG_ERROR, _("command failed to execute correctly\n")); retval = 1; } + } else if(WIFSIGNALED(status) != 0) { + _alpm_log(handle, ALPM_LOG_ERROR, _("command terminated by signal %d\n"), + WTERMSIG(status)); + retval = 1; } }
-- 1.8.3.4
On Tue, Aug 20, 2013 at 02:39:22PM -0500, Dan McGee wrote:
On Tue, Aug 20, 2013 at 2:03 PM, Dave Reisner <dreisner@archlinux.org> wrote:
Fixes FS#36618.
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- We *could* print the signal name here as well, but signal value-to-name can actually vary by architecture so it's not clear that it's something we necessarily want to get into....
These would be documented in signal(7) on most platforms, and likely signal(3) on others, right? I doubt it makes sense to point there, but I do see strsignal () which appears to be reasonably portable:
CONFORMING TO POSIX.1-2008. Present on Solaris and the BSDs.
Whoa. Had no idea this existed. This seems to return a human readable string such as "Segmentation Fault" or "Aborted" rather than the signal name, which I don't particularly think is useful. Regardless of the output, the end result from anything hitting this code path should be a bug report.
lib/libalpm/util.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index f1f760a..4b708ff 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -599,6 +599,10 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) _alpm_log(handle, ALPM_LOG_ERROR, _ ("command failed to execute correctly\n")); retval = 1; } + } else if(WIFSIGNALED(status) != 0) { + _alpm_log(handle, ALPM_LOG_ERROR, _("command terminated by signal %d\n"), + WTERMSIG(status)); + retval = 1; } }
-- 1.8.3.4
Fixes FS#36618. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- v2: Use strsignal to explain the signal in addition to reporting the value. lib/libalpm/util.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index f1f760a..19a8612 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -599,6 +599,15 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) _alpm_log(handle, ALPM_LOG_ERROR, _("command failed to execute correctly\n")); retval = 1; } + } else if(WIFSIGNALED(status) != 0) { + char *signal_description = strsignal(WTERMSIG(status)); + /* strsignal can return NULL on some (non-Linux) platforms */ + if(signal_description == NULL) { + signal_description = _("Unknown signal"); + } + _alpm_log(handle, ALPM_LOG_ERROR, _("command terminated by signal %d: %s\n"), + WTERMSIG(status), signal_description); + retval = 1; } } -- 1.8.3.4
participants (3)
-
Dan McGee
-
Dave Reisner
-
Dave Reisner