[igt-dev] [PATCH i-g-t] runner: Add signal sender name when dying

Chris Wilson chris at chris-wilson.co.uk
Wed Sep 18 10:35:18 UTC 2019


We want to know who sent us the fatal signal, for there are plenty of
fingers to go around.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala at intel.com>
---
 runner/executor.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/runner/executor.c b/runner/executor.c
index c1cfcce83..f7183293d 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -609,6 +609,26 @@ static bool kill_child(int sig, pid_t child)
 	return true;
 }
 
+static const char *get_cmdline(pid_t pid, char *buf, size_t len)
+{
+	int fd;
+
+	if (snprintf(buf, len, "/proc/%d/cmdline", pid) > len)
+		return "unknown";
+
+	fd = open(buf, O_RDONLY);
+	if (fd < 0)
+		return "unknown";
+
+	len = read(fd, buf, len - 1);
+	close(fd);
+	if (len < 0)
+		return "unknown";
+
+	buf[len] = '\0';
+	return buf;
+}
+
 /*
  * Returns:
  *  =0 - Success
@@ -886,9 +906,14 @@ static int monitor_output(pid_t child,
 				}
 			} else {
 				/* We're dying, so we're taking them with us */
-				if (settings->log_level >= LOG_LEVEL_NORMAL)
-					outf("Abort requested via %s, terminating children\n",
+				if (settings->log_level >= LOG_LEVEL_NORMAL) {
+					char comm[80];
+
+					outf("Abort requested by %s [%d] via %s, terminating children\n",
+					     get_cmdline(siginfo.ssi_pid, comm, sizeof(comm)),
+					     siginfo.ssi_pid,
 					     strsignal(siginfo.ssi_signo));
+				}
 
 				aborting = true;
 				timeout = 2;
-- 
2.23.0



More information about the igt-dev mailing list