From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 09 08:56:20 2021 Received: (at submit) by debbugs.gnu.org; 9 Feb 2021 13:56:20 +0000 Received: from localhost ([127.0.0.1]:52901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9TV6-000138-9I for submit@debbugs.gnu.org; Tue, 09 Feb 2021 08:56:20 -0500 Received: from lists.gnu.org ([209.51.188.17]:41462) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9TV4-000130-BK for submit@debbugs.gnu.org; Tue, 09 Feb 2021 08:56:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9TV3-0008VI-SC for bug-guile@gnu.org; Tue, 09 Feb 2021 08:56:17 -0500 Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9TV1-0007Vz-9p for bug-guile@gnu.org; Tue, 09 Feb 2021 08:56:17 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1612878972; cv=none; d=zohomail.com; s=zohoarc; b=YRggALCU94EbdfvhROtESoWi+DcFNVcD08OnQLkofNSblfEG+Tg21/Xq+xkV0kVn+0wyJYIMdViwXMMHerfGqL21K70eKcpcq2OdZ+dNki2Ck0oFm09AZ5ZyLUpIFHQKHAwtHYLr52fQa9ABbYP5WBAzcdoZj94KytoeykGGDnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612878972; h=Content-Type:Content-Transfer-Encoding:Date:From:MIME-Version:Message-ID:Subject:To; bh=7YTDHQM3+QuGblMMG8iprQ4+xLXhlN9yLkh/p2UVdxg=; b=bYUcVG0EasxZ99nPX6i4JNQ8fAQvi/a6Am+ADN5DfCUPWT7zWiOuqw9rlAILXU3yvKXR1QuKutiv2wP7INq9KHmsiLCNI1un0b3n0vCAMDURvtjyWBlBiOf9luONEwIGeeiFR0sS92uM6K/abKzAkVZv+/a9oJsjkYXvRbIt4Vs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1612878972; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=7YTDHQM3+QuGblMMG8iprQ4+xLXhlN9yLkh/p2UVdxg=; b=U0ubVyqu376QwYfIJ6D9wIHej1iycRwAyGxpduE5V1pyU6oCi6wyVtgrxKf7FN+N ZgkioEO5uw47wOUTLBHqfnEIOptLoJTJIZ7KhSV2aNqxdOIeuj6tnsxFHU73NyL03An fbulAInmWgS/19TLs2dGwHwCGXSs65KTs+Qo1V1Y= Received: from localhost (p54ad4a28.dip0.t-ipconnect.de [84.173.74.40]) by mx.zohomail.com with SMTPS id 161287896961138.62476504737833; Tue, 9 Feb 2021 05:56:09 -0800 (PST) User-agent: mu4e 1.4.14; emacs 27.1 From: Ricardo Wurmus To: bug-guile@gnu.org Subject: SIGINT ignored when using system* X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Tue, 09 Feb 2021 14:56:06 +0100 Message-ID: <87zh0dqr9l.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.51; envelope-from=rekado@elephly.net; helo=sender4-of-o51.zoho.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) I execute commands in a loop and wish to be able to interrupt the loop with SIGINT. Here=E2=80=99s the first attempt: guile -c \ '(for-each (lambda (n) (display n) (system* "sleep" "3")) (list 1 2 3 4))' At no point will this program be interrupted by SIGINT. Strace reveals that SIGINT is in fact received and the sleep is interrupted, but the wait is restarted immediately afterward. This program on the other hand *can* be interrupted at any point: guile -c \ '(for-each (lambda (n) (if (zero? (primitive-fork)) (begin (display n) (execlp "sleep" "sleep" "3")) (waitpid WAIT_ANY))) (list 1 2 3 4))' Is this by design? --=20 Ricardo From debbugs-submit-bounces@debbugs.gnu.org Sat May 01 19:19:20 2021 Received: (at 46403) by debbugs.gnu.org; 1 May 2021 23:19:20 +0000 Received: from localhost ([127.0.0.1]:38958 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lcytM-0006ry-Am for submit@debbugs.gnu.org; Sat, 01 May 2021 19:19:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46142) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lcytJ-0006rm-Tx for 46403@debbugs.gnu.org; Sat, 01 May 2021 19:19:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50917) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcytE-0007gn-JF; Sat, 01 May 2021 19:19:12 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=46110 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lcytE-0007EY-71; Sat, 01 May 2021 19:19:12 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Ricardo Wurmus Subject: Re: bug#46403: SIGINT ignored when using system* References: <87zh0dqr9l.fsf@elephly.net> Date: Sun, 02 May 2021 01:19:10 +0200 In-Reply-To: <87zh0dqr9l.fsf@elephly.net> (Ricardo Wurmus's message of "Tue, 09 Feb 2021 14:56:06 +0100") Message-ID: <87wnsi59g1.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 46403 Cc: 46403@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! Ricardo Wurmus skribis: > I execute commands in a loop and wish to be able to interrupt the loop > with SIGINT. Here=E2=80=99s the first attempt: > > guile -c \ > '(for-each (lambda (n) > (display n) > (system* "sleep" "3")) > (list 1 2 3 4))' > > At no point will this program be interrupted by SIGINT. Strace reveals > that SIGINT is in fact received and the sleep is interrupted, but the > wait is restarted immediately afterward. =E2=80=98system*=E2=80=99 explicitly ignores SIGINT: --8<---------------cut here---------------start------------->8--- /* Make sure the child can't kill us (as per normal system call). */ scm_dynwind_sigaction (SIGINT, scm_from_uintptr_t ((uintptr_t) SIG_IGN), SCM_UNDEFINED); --8<---------------cut here---------------end--------------->8--- Indeed, system(3) says: During execution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored, in the process that calls system(). (These signals will be handled according to their defaults inside the child process that executes command.) (I did some archaeology and found it has always been this way since Rob introduced =E2=80=98system*=E2=80=99 in 0db17ef9abd59da51ebc30d90fb2dc482b0= 2a4a1.) > Is this by design? I think so! Ludo=E2=80=99.