[igt-dev] [PATCH i-g-t] runner: Show more elements of the signaler's argv[]

Petri Latvala petri.latvala at intel.com
Mon Sep 23 13:08:50 UTC 2019


On Mon, Sep 23, 2019 at 12:20:11PM +0100, Chris Wilson wrote:
> /proc/$pid/cmdline is the entire argv[] including NUL-terminator.
> Replace the NULs with spaces so we get a better idea of who the
> signaler was, as often it is a subprocess (such as a child of sudo,
> or worse java).
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Petri Latvala <petri.latvala at intel.com>

Reviewed-by: Petri Latvala <petri.latvala at intel.com>



> ---
>  runner/executor.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/runner/executor.c b/runner/executor.c
> index f7183293d..91e8a7b20 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -625,7 +625,12 @@ static const char *get_cmdline(pid_t pid, char *buf, size_t len)
>  	if (len < 0)
>  		return "unknown";
>  
> -	buf[len] = '\0';
> +	/* cmdline is the whole argv[], completed with NUL-terminators */
> +	for (size_t i = 0; i < len; i++)
> +		if (buf[i] == '\0')
> +			buf[i] = ' ';
> +
> +	buf[len] = '\0'; /* but make sure that we return a valid string! */
>  	return buf;
>  }
>  
> @@ -907,7 +912,7 @@ 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) {
> -					char comm[80];
> +					char comm[120];
>  
>  					outf("Abort requested by %s [%d] via %s, terminating children\n",
>  					     get_cmdline(siginfo.ssi_pid, comm, sizeof(comm)),
> -- 
> 2.23.0
> 


More information about the igt-dev mailing list