From patchwork Thu Dec 14 11:02:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10111861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7B61760327 for ; Thu, 14 Dec 2017 11:02:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EF6629B89 for ; Thu, 14 Dec 2017 11:02:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6264129B9F; Thu, 14 Dec 2017 11:02:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA12A28E96 for ; Thu, 14 Dec 2017 11:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751462AbdLNLCp (ORCPT ); Thu, 14 Dec 2017 06:02:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44936 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbdLNLCo (ORCPT ); Thu, 14 Dec 2017 06:02:44 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CECED4900E; Thu, 14 Dec 2017 11:02:44 +0000 (UTC) Received: from dhcp-13-42.nay.redhat.com (unknown [10.66.128.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77B416A510; Thu, 14 Dec 2017 11:02:42 +0000 (UTC) From: Honggang LI To: linux-rdma@vger.kernel.org Cc: honli@redhat.com, jgunthorpe@obsidianresearch.com Subject: [PATCH rdma-core] srp_daemon: Install signal handler for ibsrpdm Date: Thu, 14 Dec 2017 19:02:41 +0800 Message-Id: <20171214110241.4701-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 14 Dec 2017 11:02:44 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Honggang Li [root@localhost ~]# /usr/sbin/ibsrpdm -c -d /dev/infiniband/umad0 id_ext=0002c90300317810,ioc_guid=0002c90300317810,dgid=fe800000000000000002c90300317811,pkey=ffff,service_id=0002c90300317810 [root@localhost ~]# echo $? 130 fd3005f0cd34 moves the signal handler setup from ibsrpdm path. So, default signal handler will be used when it receives signal SIGINT. ibsrpdm will exit with non-zero exit code as default signal handler killed it. ibsrpdm should return with exit code zero, if no error emerged. main->ibsrpdm->free_res->pthread_kill(res->async_ev_thread, SIGINT) Beside the wrong exit code, there is an extra blank line at the end of output of ibsrpdm. Fixes: fd3005f0cd34 ("srp_daemon: Move the setup of the wakeup_pipe after openlog") Signed-off-by: Honggang Li --- srp_daemon/srp_daemon.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon.c index cec36db2..0d00d712 100644 --- a/srp_daemon/srp_daemon.c +++ b/srp_daemon/srp_daemon.c @@ -1996,7 +1996,6 @@ static void cleanup_wakeup_fd(void) static int setup_wakeup_fd(void) { - struct sigaction sa = {}; int ret; ret = pipe2(wakeup_pipe, O_NONBLOCK | O_CLOEXEC); @@ -2005,11 +2004,6 @@ static int setup_wakeup_fd(void) return -1; } - sigemptyset(&sa.sa_mask); - sa.sa_handler = signal_handler; - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - sigaction(SRP_CATAS_ERR, &sa, NULL); return 0; } @@ -2100,6 +2094,7 @@ int main(int argc, char *argv[]) int lockfd = -1; int received_signal = 0; bool systemd; + struct sigaction sa = {}; #ifndef __CHECKER__ /* @@ -2117,6 +2112,12 @@ int main(int argc, char *argv[]) BUILD_ASSERT(sizeof(struct srp_dm_iou_info) == 132); BUILD_ASSERT(sizeof(struct srp_dm_ioc_prof) == 128); + sigemptyset(&sa.sa_mask); + sa.sa_handler = signal_handler; + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + sigaction(SRP_CATAS_ERR, &sa, NULL); + if (strcmp(argv[0] + max_t(int, 0, strlen(argv[0]) - strlen("ibsrpdm")), "ibsrpdm") == 0) { ret = ibsrpdm(argc, argv);