[Intel-gfx] [PATCH i-g-t 5/5] lib: print a message when receiving a handled signal
Chris Wilson
chris at chris-wilson.co.uk
Wed Dec 17 10:12:19 PST 2014
On Wed, Dec 17, 2014 at 04:45:47PM +0000, Thomas Wood wrote:
> Signed-off-by: Thomas Wood <thomas.wood at intel.com>
> ---
> 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
More information about the Intel-gfx
mailing list