From f691f4c304d226f99ac0377de3b6186154c0d8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6tzel?= Date: Fri, 4 Mar 2022 10:08:14 +0100 Subject: [PATCH] Use correct signal oldset in posix_spawn implementation * src/callproc.c (emacs_spawn): Pass oldset parameter. (emacs_posix_spawn_init_attributes): Use correct oldset. (emacs_posix_spawn_init): remove intermediate function. --- src/callproc.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/src/callproc.c b/src/callproc.c index 018c9ce690..0922e10f01 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1335,7 +1335,8 @@ emacs_posix_spawn_init_actions (posix_spawn_file_actions_t *actions, } static int -emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes) +emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes, + const sigset_t *oldset) { int error = posix_spawnattr_init (attributes); if (error != 0) @@ -1377,11 +1378,7 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes) goto out; /* Stop blocking SIGCHLD in the child. */ - sigset_t oldset; - error = pthread_sigmask (SIG_SETMASK, NULL, &oldset); - if (error != 0) - goto out; - error = posix_spawnattr_setsigmask (attributes, &oldset); + error = posix_spawnattr_setsigmask (attributes, oldset); if (error != 0) goto out; @@ -1392,23 +1389,6 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes) return error; } -static int -emacs_posix_spawn_init (posix_spawn_file_actions_t *actions, - posix_spawnattr_t *attributes, int std_in, - int std_out, int std_err, const char *cwd) -{ - int error = emacs_posix_spawn_init_actions (actions, std_in, - std_out, std_err, cwd); - if (error != 0) - return error; - - error = emacs_posix_spawn_init_attributes (attributes); - if (error != 0) - return error; - - return 0; -} - #endif /* Start a new asynchronous subprocess. If successful, return zero @@ -1443,9 +1423,12 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, if (use_posix_spawn) { /* Initialize optional attributes before blocking. */ - int error - = emacs_posix_spawn_init (&actions, &attributes, std_in, - std_out, std_err, cwd); + int error = emacs_posix_spawn_init_actions (&actions, std_in, + std_out, std_err, cwd); + if (error != 0) + return error; + + error = emacs_posix_spawn_init_attributes (&attributes, oldset); if (error != 0) return error; } -- 2.35.1