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

Petri Latvala petri.latvala at intel.com
Wed Sep 18 10:45:33 UTC 2019


On Wed, Sep 18, 2019 at 11:35:18AM +0100, Chris Wilson wrote:
> 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;
> +}

Are you intentionally only printing argv[0]? argv items are
\0-separated in /proc/*/cmdline.



-- 
Petri Latvala


More information about the igt-dev mailing list