From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 1D6305A026D for ; Thu, 13 Apr 2023 15:13:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681391610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wulv4mqOZAf8gDdwFOaTihDpm2Ab+1y1EKz4PTIehYY=; b=FQ4e578yJZwVOhOgjsvP/HHrD0DTBpHD4BMVVItiwz5yvAevsA/VkQ7uT82+s6YMtWMlbd h5YX2M0s/dsSM6n6QsFkX05Emj8PYxxme8AdEahytd1QVp2tV5N1VSR9xKSmkoSM9ZuI0v wiC29jL9CPv5r001J3DtXeVJ6KR1fQA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-jfxVXU0xOA-C9ZrLsVVkmw-1; Thu, 13 Apr 2023 09:13:29 -0400 X-MC-Unique: jfxVXU0xOA-C9ZrLsVVkmw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 08A74858289; Thu, 13 Apr 2023 13:13:29 +0000 (UTC) Received: from maya.cloud.tilaa.com (unknown [10.33.32.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB10B1121320; Thu, 13 Apr 2023 13:13:28 +0000 (UTC) Date: Thu, 13 Apr 2023 13:25:05 +0200 From: Stefano Brivio To: Valtteri Vuorikoski Subject: Re: passt.c: incorrect signal() return value check Message-ID: <20230413132505.2b0c8e52@elisabeth> In-Reply-To: References: Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: ZORAD3LLW23PLZVCCXXXE2B23KKIQ23Y X-Message-ID-Hash: ZORAD3LLW23PLZVCCXXXE2B23KKIQ23Y X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Hi Valtteri, On Thu, 13 Apr 2023 13:24:34 +0300 Valtteri Vuorikoski wrote: > In current master, passt.c:main() has an incorrect check on signal() > return value: > > if (sigaction(SIGCHLD, &sa, NULL) || signal(SIGPIPE, SIG_IGN)) > die("Couldn't install signal handlers"); > > signal() returns SIG_ERR on failure or the previous setting if present. If > a setting has been inherited from the parent (as is the case when > starting from systemd with the default setting of IgnoreSIGPIPE=yes), > the check will fail. Right, thanks for reporting this. By the way, feel free to share your systemd unit files, I guess we could add them under contrib/ in case they are useful for somebody. > The if statement should check for SIG_ERR for the SIGPIPE case, or > alternatively switch to sigaction() since that's used for everything > else in the code. I guess we could just check SIG_ERR from signal(), it looks a bit simpler, and perhaps split this into two cases (a failure on signal() doesn't mean we "[c]ouldn't install signal handlers"). Will you post a patch? It's trivial, so if it's unnecessary effort for you I can also go ahead and do it. > -Valtteri > (please cc on replies) -- Stefano