From patchwork Thu Feb 19 14:30:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5852251 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D79969F373 for ; Thu, 19 Feb 2015 14:30:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 105F52025A for ; Thu, 19 Feb 2015 14:30:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 40ECB20259 for ; Thu, 19 Feb 2015 14:30:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 926466E19B; Thu, 19 Feb 2015 06:30:23 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by gabe.freedesktop.org (Postfix) with ESMTP id A6FBF6E19B for ; Thu, 19 Feb 2015 06:30:21 -0800 (PST) Received: by mail-wg0-f47.google.com with SMTP id x12so7558342wgg.6 for ; Thu, 19 Feb 2015 06:30:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=JxUYkgRcTbr6EXlgeJERKjN+Ggq6q9PmCticQYIC/bU=; b=aYS5z/zkjLfq30gh+kUX5U6CnxP+aQtyJkOYkXktYw2+IdHxLu3+Tqxdlntr5Wblpj AucgvAzQHyElVbKtPPpsJp0uPal2AgfPb9p3DIwAbFviskulbQm0RCzSAIgq4AeDfuFG bItdBLbi1HQsQEdZVFZFREolaRLNgVnP2GmRHiXnXd2zThoyXXUNCje2RvUUmoJqT8hZ RlaSmrYMfKsdHNgDT5QttDVRIKdoJliyzzyTwdVKqz3LW3vrOVh23ksq5cZeNJ0PB8Rr Le/t74DrN7Rt3XbA5yzMmPiqQv9JhXFUbR76fW81M7dRl7uDV/q3jDPNlzGvSeMBpzOl LeXg== X-Gm-Message-State: ALoCoQnhp31Kn8BKwxl/tkjCXoH4ESJlpr5vVuod7I/LPIVqs5POYYazQYVnHQl00mu6P+jcczjy X-Received: by 10.180.19.193 with SMTP id h1mr4276832wie.2.1424356219649; Thu, 19 Feb 2015 06:30:19 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id uo6sm37620701wjc.49.2015.02.19.06.30.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 06:30:18 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Thu, 19 Feb 2015 14:30:17 +0000 Message-Id: <1424356217-17766-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 Subject: [Intel-gfx] [PATCH i-g-t] lib: print the signal name to stderr when handling a signal X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Thomas Wood --- lib/igt_core.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 75b98f6..adfa597 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1303,8 +1303,10 @@ static struct { static igt_exit_handler_t exit_handler_fn[MAX_EXIT_HANDLERS]; static bool exit_handler_disabled; static sigset_t saved_sig_mask; -static const int handled_signals[] = - { SIGINT, SIGHUP, SIGTERM, SIGQUIT, SIGPIPE, SIGABRT, SIGSEGV, SIGBUS }; +#define SIGDEF(x) { x, #x, sizeof(#x) - 1 } +static const struct { int number; const char *name; size_t name_len; } handled_signals[] = + { SIGDEF(SIGINT), SIGDEF(SIGHUP), SIGDEF(SIGTERM), SIGDEF(SIGQUIT), + SIGDEF(SIGPIPE), SIGDEF(SIGABRT), SIGDEF(SIGSEGV), SIGDEF(SIGBUS) }; static int install_sig_handler(int sig_num, sighandler_t handler) { @@ -1357,8 +1359,20 @@ static void igt_atexit_handler(void) static void fatal_sig_handler(int sig) { + int i; + restore_all_sig_handler(); + for (i = 0; i < ARRAY_SIZE(handled_signals); i++) { + if (handled_signals[i].number == sig) { + write(STDERR_FILENO, "Received signal ", 16); + write(STDERR_FILENO, handled_signals[i].name, + handled_signals[i].name_len); + write(STDERR_FILENO, ".\n", 2); + break; + } + } + /* * exit_handler_disabled is always false here, since when we set it * we also block signals. @@ -1415,7 +1429,7 @@ void igt_install_exit_handler(igt_exit_handler_t fn) return; for (i = 0; i < ARRAY_SIZE(handled_signals); i++) { - if (install_sig_handler(handled_signals[i], + if (install_sig_handler(handled_signals[i].number, fatal_sig_handler)) goto err; } @@ -1447,7 +1461,7 @@ void igt_disable_exit_handler(void) sigemptyset(&set); for (i = 0; i < ARRAY_SIZE(handled_signals); i++) - sigaddset(&set, handled_signals[i]); + sigaddset(&set, handled_signals[i].number); if (sigprocmask(SIG_BLOCK, &set, &saved_sig_mask)) { perror("sigprocmask");