From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?J=C3=BCrgen_H=C3=B6tzel?= Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes Date: Fri, 04 Mar 2022 16:41:15 +0100 Message-ID: <864k4dvhr6.fsf@hoetzel.info> References: <7CFD5E28-8266-4004-BF66-255146D72722@gnu.org> <83r18whunp.fsf@gnu.org> <36bbd45c-0a87-13b7-1589-afe943329e20@fastmail.com> <83ee4whqpf.fsf@gnu.org> <87v8y33hu1.fsf@rfc20.org> <83sft7aqxd.fsf@gnu.org> <3db6c69c-0c08-3f92-491b-0b715b18eb40@fastmail.com> <87pmo6c3h6.fsf@gmail.com> <86o82mvybj.fsf@hoetzel.info> <87zgm6ghdz.fsf@gmail.com> 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="13899"; mail-complaints-to="usenet@ciao.gmane.io" Cc: alan@idiocy.org, emacs-devel@gnu.org, Saulius Menkevicius , p.stephani2@gmail.com, Matt Armstrong , Eli Zaretskii , mituharu@math.s.chiba-u.ac.jp To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 04 17:03:27 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nQAOt-0003RV-A2 for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Mar 2022 17:03:27 +0100 Original-Received: from localhost ([::1]:33458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQAOr-0001Vo-UK for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Mar 2022 11:03:25 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQACy-0007oC-U7 for emacs-devel@gnu.org; Fri, 04 Mar 2022 10:51:09 -0500 Original-Received: from mout-p-101.mailbox.org ([80.241.56.151]:41348) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1nQACw-0003if-EU; Fri, 04 Mar 2022 10:51:08 -0500 Original-Received: from smtp202.mailbox.org (smtp202.mailbox.org [80.241.60.245]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4K9C4l0zSzz9sc2; Fri, 4 Mar 2022 16:51:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hoetzel.info; s=MBO0001; t=1646409061; 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=+o31/gfmgKy1cZ1H73v72f/Lx5XWyz62OW0luBrLAiQ=; b=ZQ/voXrtxTjoaO0n9hJTs/FKalzIRUrwwWlXN/ThpcqJlLi4uV7i8MRsoWsxF4JwEInPLM l60ToXTZwLt0GAy3OnZBz1rRBEGYeGtu1BGb/0iYxsMnjbSTMaPpya9Wv9lV5DpKkGyZXl 6H7UMjN6fYxEWY8Ubdav5vv3jLlTk94tagRePnBqwvOIa/g70WPBve3A4tjB/6vLgAyp3Z 8f/IrGQvz5YrpdwkuxEJhdA153h1QY6B2K5nyr/u7QPzSUhZKOF87DilBRp89t3YepyCXo 0HqNdS4zkACXe1/DJvjsNAYTC28desYUNQa43E8w97ZoE9S3vy3F8Zml23A2QA== In-reply-to: <87zgm6ghdz.fsf@gmail.com> Received-SPF: pass client-ip=80.241.56.151; envelope-from=juergen@hoetzel.info; helo=mout-p-101.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286824 Archived-At: Robert Pluim writes: >>>>>> On Fri, 04 Mar 2022 09:38:25 +0100, J=C3=BCrgen H=C3=B6tzel said: > J=C3=BCrgen> IMO the correct way to fix this issue is to use the olds= et passed by > J=C3=BCrgen> emacs_spawn (patch enclosed) just like the fork/exec imp= lementation does. > > Sure, that would work as well. > > J=C3=BCrgen> I guess without a fix many forking commands (that don't = examine and > J=C3=BCrgen> change mask of blocked signals) will "hang" in Emacs. > > Not really. It=CA=BCs a code path that=CA=BCs non-default, since > process-connection-type defaults to t =3D> use pty's, and the command in =E2=80=98call-process=E2=80=99 invokes emacs_spawn 'call-process' with pty = set to NULL so =E2=80=98process-connection-type=E2=80=99 doesn't have an effect here. A minimal C example to reproduce the HANG is --8<---------------cut here---------------start hang.c------------->8--- #include #include #include #include void chld_handler(int signum) { printf("\nInside CHLD handler function\n");= } int main(int argc, char *argv[]) { sigset_t blocked, old; signal(SIGCHLD, chld_handler); // Setup Child handler sigemptyset(&blocked); sigaddset(&blocked, SIGCHLD); sigprocmask(SIG_BLOCK, &blocked, &old); if (!fork()) { return 0; /* child signals SIGCHLD */ } sigsuspend(&old); /* WAITS for ever when SIGCHILD was originally blocked = */ printf("Parent terminates\n"); return 0; } --8<---------------cut here---------------end hang.c--------------->8--- (call-process "chldtest" nil t nil) will never return. Regards, J=C3=BCrgen