From patchwork Mon Apr 27 03:38:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 1277300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499VrG4y0Hz9sRY for ; Mon, 27 Apr 2020 13:39:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=WyzkY1xu; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 499VrG3XzbzDqML for ; Mon, 27 Apr 2020 13:39:10 +1000 (AEST) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=WyzkY1xu; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 499Vqg02W1zDqVD for ; Mon, 27 Apr 2020 13:38:38 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=iJz/tG5W35N11XjRTjMjRw9ASzD0T5jDqhMbbCwy1YA=; b=WyzkY1xumCEGayKNJj3K3qqLQz VbVBgWANH2CyjU7ICJc2zYJlFnSnlsjjuqSZpYA+sLZW3xWV9Za1SObeqTbpbnuz1u6HTZ9RvlCKe Qr/EQNWgf1edd0jkzoWL2eNC4NJIJsWAxtiz2ENPNop5pz80SR557PNA8PfYNL5zifT/6kFPEr7Kk 27IBSwJzI1cZ9ikKWwWmmuu/jccUFIEZxNh5w55pJanw8SP1dfhRbwZl9UFbDHzywQ8UXMG3DIH0p +0Av7b1Xo6qslgLWSBNiG5WfeCWKyalf+k557ug3FpAvCdVx/L2yHCN78gxQsb5+OKWWaILO9rIxl djcwdOjQ==; Received: from geoff by merlin.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSubH-0005VV-7E; Mon, 27 Apr 2020 03:38:31 +0000 Message-Id: In-Reply-To: References: From: Geoff Levand Patch-Date: Sun, 26 Apr 2020 20:14:07 -0700 Subject: [PATCH v1 4/5] pb-discover: Fix signal handler To: Jeremy Kerr Date: Mon, 27 Apr 2020 03:38:31 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Variables shared between signal handlers and the main program need to be of type 'volatile sig_atomic_t'. Also, after a signal is serviced it should be re-enabled, so add a call to signal() in the handler. Signed-off-by: Geoff Levand --- discover/pb-discover.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/discover/pb-discover.c b/discover/pb-discover.c index e2b36dd..f67eea5 100644 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -113,11 +113,12 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) return optind != argc; } -static int running; +static volatile sig_atomic_t running; -static void sigint_handler(int __attribute__((unused)) signum) +static void sigint_handler(int signum) { running = 0; + signal(signum, sigint_handler); } int main(int argc, char *argv[])