unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jürgen Hötzel" <juergen@hoetzel.info>
To: Robert Pluim <rpluim@gmail.com>
Cc: alan@idiocy.org, emacs-devel@gnu.org,
	Saulius Menkevicius <sauliusmenkevicius@fastmail.com>,
	p.stephani2@gmail.com, Matt Armstrong <matt@rfc20.org>,
	Eli Zaretskii <eliz@gnu.org>,
	mituharu@math.s.chiba-u.ac.jp
Subject: Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
Date: Fri, 04 Mar 2022 16:41:15 +0100	[thread overview]
Message-ID: <864k4dvhr6.fsf@hoetzel.info> (raw)
In-Reply-To: <87zgm6ghdz.fsf@gmail.com>


Robert Pluim <rpluim@gmail.com> writes:

>>>>>> On Fri, 04 Mar 2022 09:38:25 +0100, Jürgen Hötzel <juergen@hoetzel.info> said:
>     Jürgen> IMO the correct way to fix this issue is to use the oldset passed by
>     Jürgen> emacs_spawn (patch enclosed) just like the fork/exec implementation does.
>
> Sure, that would work as well.
>
>     Jürgen> I guess without a fix many forking commands (that don't examine and
>     Jürgen> change mask of blocked signals) will "hang" in Emacs.
>
> Not really. Itʼs a code path thatʼs non-default, since
> process-connection-type defaults to t => use pty's, and the command in

‘call-process’ invokes emacs_spawn 'call-process' with pty set to NULL
so ‘process-connection-type’ doesn't have an effect here.

A minimal C example to reproduce the HANG is

--8<---------------cut here---------------start hang.c------------->8---
#include <signal.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>

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ürgen




  reply	other threads:[~2022-03-04 15:41 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25  6:48 master 2c79a8f 2/2: Use posix_spawn if possible Saulius Menkevicius
2022-01-25  8:41 ` Eli Zaretskii
2022-01-25  8:58   ` Saulius Menkevicius
2022-01-25 11:46     ` Jostein Kjønigsen
2022-01-25 11:55       ` Po Lu
2022-01-25 12:22     ` Eli Zaretskii
2022-01-25 12:25       ` Saulius Menkevicius
2022-01-25 13:47         ` Eli Zaretskii
2022-01-28 17:12           ` Matt Armstrong
2022-01-29  8:03             ` Saulius Menkevičius
2022-01-29  8:26             ` Eli Zaretskii
2022-01-31 20:48               ` Saulius Menkevicius
2022-02-01  9:59                 ` Robert Pluim
2022-02-01 18:30                   ` Saulius Menkevicius
2022-02-01 19:23                     ` Robert Pluim
2022-02-01 19:52                       ` Eli Zaretskii
2022-02-02  8:30                         ` Robert Pluim
2022-02-02  8:54                           ` Saulius Menkevičius
2022-02-07 21:12                             ` Saulius Menkevicius
2022-02-08  8:27                               ` Robert Pluim
2022-02-08 12:12                               ` Eli Zaretskii
2022-02-08 12:18                                 ` Saulius Menkevicius
2022-02-08 14:59                                   ` Robert Pluim
2022-02-08 21:09                                     ` Saulius Menkevicius
2022-02-09  8:48                                       ` Robert Pluim
2022-02-12  8:44                                         ` Saulius Menkevicius
2022-02-12  8:59                                           ` Eli Zaretskii
2022-02-12  9:42                                             ` Saulius Menkevicius
2022-03-04  8:38                   ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes (was: Re: master 2c79a8f 2/2: Use posix_spawn if possible.) Jürgen Hötzel
2022-03-04 10:07                     ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes Robert Pluim
2022-03-04 15:41                       ` Jürgen Hötzel [this message]
2022-03-04 16:08                         ` Robert Pluim
2022-04-17 18:22                         ` Philipp Stephani
2022-04-19 14:36                           ` Robert Pluim
2022-04-19 14:48                             ` Philipp Stephani
2022-04-19 16:07                             ` Eli Zaretskii
2022-04-19 17:32                               ` Robert Pluim
2022-04-04 14:13                       ` Robert Pluim
2022-01-25 13:15 ` master 2c79a8f 2/2: Use posix_spawn if possible Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=864k4dvhr6.fsf@hoetzel.info \
    --to=juergen@hoetzel.info \
    --cc=alan@idiocy.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=matt@rfc20.org \
    --cc=mituharu@math.s.chiba-u.ac.jp \
    --cc=p.stephani2@gmail.com \
    --cc=rpluim@gmail.com \
    --cc=sauliusmenkevicius@fastmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).