From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Newsgroups: gmane.lisp.guile.bugs Subject: bug#70144: system* affects signal handlers Date: Thu, 02 May 2024 16:17:49 +0200 Message-ID: <877cgcxppu.fsf@gnu.org> References: <87msqbrga2.fsf@cbaines.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33555"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 70144@debbugs.gnu.org, Josselin Poiret , Christopher Baines To: Mikael Djurfeldt Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Thu May 02 16:19:00 2024 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s2XH2-0008VV-Ba for guile-bugs@m.gmane-mx.org; Thu, 02 May 2024 16:19:00 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2XGl-00042k-5H; Thu, 02 May 2024 10:18:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2XGj-00042U-69 for bug-guile@gnu.org; Thu, 02 May 2024 10:18:41 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2XGi-0007nX-Jk for bug-guile@gnu.org; Thu, 02 May 2024 10:18:40 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s2XH4-0006XD-Ch for bug-guile@gnu.org; Thu, 02 May 2024 10:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 02 May 2024 14:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70144 X-GNU-PR-Package: guile Original-Received: via spool by 70144-submit@debbugs.gnu.org id=B70144.171465950525113 (code B ref 70144); Thu, 02 May 2024 14:19:02 +0000 Original-Received: (at 70144) by debbugs.gnu.org; 2 May 2024 14:18:25 +0000 Original-Received: from localhost ([127.0.0.1]:44082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2XGT-0006Wz-Cj for submit@debbugs.gnu.org; Thu, 02 May 2024 10:18:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2XGQ-0006Ws-O7 for 70144@debbugs.gnu.org; Thu, 02 May 2024 10:18:24 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2XFx-0007ec-Oc; Thu, 02 May 2024 10:17:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=S4c0rckFQVB4jrbkSdTQ4oX/pk0dlPzOlQuCYndT3Ks=; b=Nqx2FymKXgHlvEwoElvO /FmuK9PE21FUFmEpm/L1WMIu3iwcLl0MvfvIyzWT6PNQ3xIp1b82VNwjLw9NASLczRaTpqDsp1Lzj yecg+QErN+RFIMR3DXO+ylZL5xpYQp/UhAyHfX1TpMQzsCu+KJFo/lc6pnjiW2ulYaVBZwYTPOFVd nE5oeJVXCjqHzUs1MtfMhypRgH97tSIb5VL6MN0T0emCXKJjqwMEaXPvi7AZBwjpuCmO+Zwnf56L3 U89uviLPYkThSNj8IXzi7Z9No2QJotiq1ysKPGQLk/d3oFqO0W9qNrW8sMnIH9DS56FEkt9d6sWrh BdpYSFnPkQqPuQ==; In-Reply-To: (Mikael Djurfeldt's message of "Wed, 3 Apr 2024 10:28:09 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.bugs:10826 Archived-At: Hi, Mikael Djurfeldt skribis: > system* temporarily re-binds signal handlers to prevent the child process > from killing the parent. Thus, it is not thread safe with regard to SIGINT > (or SIGQUIT if available). So, your code has a race condition with respect > to the signal handler. This common resource can, in principle, be handled > the usual way by, for example, utilizing a mutex: [...] > I'm leaving this bug open. *Should* system* re-bind the signal handlers? > Should it really protect itself from the child? If so, we should probably > document this behaviour in the reference manual. Unless I=E2=80=99m mistaken, we can remove the =E2=80=98scm_dynwind_sigacti= on=E2=80=99 calls from =E2=80=98scm_system_star=E2=80=99: now that we use =E2=80=98posix_spaw= n=E2=80=99, this is all taken care of. This can be seen by running: strace -o /tmp/log.strace -f guile -c '(system* "/bin/sh" "-c" "echo foo = $$")' =E2=80=A6 which shows pre-fork signal blocking (this is =E2=80=98internal_signal_block_all=E2=80=99 in spawni.c in glibc) followed,= in the child (PID 28592 here), by a long series of =E2=80=98sigaction=E2=80=99 calls to = reset handlers to their default behavior: --8<---------------cut here---------------start------------->8--- 28586 rt_sigprocmask(SIG_BLOCK, ~[], [], 8) =3D 0 28586 clone3({flags=3DCLONE_VM|CLONE_VFORK, exit_signal=3DSIGCHLD, stack=3D= 0x7f73b39b2000, stack_size=3D0x9000}, 88 28592 rt_sigprocmask(SIG_BLOCK, NULL, ~[KILL STOP], 8) =3D 0 28592 rt_sigaction(SIGHUP, NULL, {sa_handler=3DSIG_DFL, sa_mask=3D[], sa_fl= ags=3D0}, 8) =3D 0 28592 rt_sigaction(SIGHUP, {sa_handler=3DSIG_DFL, sa_mask=3D[], sa_flags=3D= SA_RESTORER, sa_restorer=3D0x7f73b432d2a0}, NULL, 8) =3D 0 28592 rt_sigaction(SIGINT, NULL, {sa_handler=3DSIG_IGN, sa_mask=3D[], sa_fl= ags=3DSA_RESTORER, sa_restorer=3D0x7f73b432d2a0}, 8) =3D 0 28592 rt_sigaction(SIGQUIT, NULL, {sa_handler=3DSIG_IGN, sa_mask=3D[], sa_f= lags=3DSA_RESTORER, sa_restorer=3D0x7f73b432d2a0}, 8) =3D 0 28592 rt_sigaction(SIGILL, NULL, {sa_handler=3DSIG_DFL, sa_mask=3D[], sa_fl= ags=3D0}, 8) =3D 0 28592 rt_sigaction(SIGILL, {sa_handler=3DSIG_DFL, sa_mask=3D[], sa_flags=3D= SA_RESTORER, sa_restorer=3D0x7f73b432d2a0}, NULL, 8) =3D 0 28592 rt_sigaction(SIGTRAP, NULL, {sa_handler=3DSIG_DFL, sa_mask=3D[], sa_f= lags=3D0}, 8) =3D 0 28592 rt_sigaction(SIGTRAP, {sa_handler=3DSIG_DFL, sa_mask=3D[], sa_flags= =3DSA_RESTORER, sa_restorer=3D0x7f73b432d2a0}, NULL, 8) =3D 0 --8<---------------cut here---------------end--------------->8--- Josselin, can you confirm? Thanks, Ludo=E2=80=99.