Re: [PATCH i-g-t 5/5] lib: print a message when receiving a handled signal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 17, 2014 at 04:45:47PM +0000, Thomas Wood wrote:
> Signed-off-by: Thomas Wood <thomas.wood@xxxxxxxxx>
> ---
>  lib/igt_core.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 925d78c..1307fa8 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -366,6 +366,7 @@ static void low_mem_killer_disable(bool disable)
>  }
>  
>  #define write_log_msg(x) write(STDERR_FILENO, x, strlen(x))
> +#define write_log_char(x) write(STDERR_FILENO, &x, 1)
>  static void clear_log(void)
>  {
>  	uint8_t i;
> @@ -439,6 +440,24 @@ static void common_exit_handler(int sig)
>  	 * called. */
>  	assert(sig != 0 || igt_exit_called);
>  
> +	if (sig) {
> +		int sigtmp;
> +		char c;
> +		int start = 1;
> +
> +		write_log_msg("--- Received signal ");
> +
> +		/* write out the signal number, in a signal safe manner */
> +		sigtmp = sig;
> +		for (sigtmp = sig; sigtmp > 10; sigtmp /= 10)
> +			start *= 10;
> +		for (; start != 0; start /= 10) {
> +			c = '0' + (sig / start) % 10;
> +			write_log_char(c);
> +		}
> +		write_log_msg("\n");
> +	}

char buf[] = "123\n";
int i = 3;
for (uint8_t s = sig; s; s /= 10) 
	buf[--i] = '0' + s % 10;
write_log_msg("--- Received signal ");
write_log_msg(buf + i); // or combined
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux