aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJürgen Hötzel2022-03-04 10:08:14 +0100
committerRobert Pluim2022-04-04 16:08:14 +0200
commit8103b060d89ac63a12c439087bd46c30da72cd97 (patch)
treec1408a83c383f0d89c32c42c8c4615e3fdc93148 /src
parente7cd4bae44585b4fc0d57fbb98f49930b945a817 (diff)
downloademacs-8103b060d89ac63a12c439087bd46c30da72cd97.tar.gz
emacs-8103b060d89ac63a12c439087bd46c30da72cd97.zip
Use correct signal oldset in posix_spawn implementation
posix_spawn was restoring the wrong signal set, which still had SIGCHLD and SIGINT masked, causing problems with child processes that spawned child processes. (Bug#54667) See the thread ending at https://lists.gnu.org/archive/html/emacs-devel/2022-03/msg00067.html for more details. * src/callproc.c (emacs_spawn): Pass oldset parameter. (emacs_posix_spawn_init_attributes): Use correct oldset. (emacs_posix_spawn_init): Remove intermediate function.
Diffstat (limited to 'src')
-rw-r--r--src/callproc.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 018c9ce6909..0922e10f01d 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1335,7 +1335,8 @@ emacs_posix_spawn_init_actions (posix_spawn_file_actions_t *actions,
1335} 1335}
1336 1336
1337static int 1337static int
1338emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes) 1338emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes,
1339 const sigset_t *oldset)
1339{ 1340{
1340 int error = posix_spawnattr_init (attributes); 1341 int error = posix_spawnattr_init (attributes);
1341 if (error != 0) 1342 if (error != 0)
@@ -1377,11 +1378,7 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes)
1377 goto out; 1378 goto out;
1378 1379
1379 /* Stop blocking SIGCHLD in the child. */ 1380 /* Stop blocking SIGCHLD in the child. */
1380 sigset_t oldset; 1381 error = posix_spawnattr_setsigmask (attributes, oldset);
1381 error = pthread_sigmask (SIG_SETMASK, NULL, &oldset);
1382 if (error != 0)
1383 goto out;
1384 error = posix_spawnattr_setsigmask (attributes, &oldset);
1385 if (error != 0) 1382 if (error != 0)
1386 goto out; 1383 goto out;
1387 1384
@@ -1392,23 +1389,6 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes)
1392 return error; 1389 return error;
1393} 1390}
1394 1391
1395static int
1396emacs_posix_spawn_init (posix_spawn_file_actions_t *actions,
1397 posix_spawnattr_t *attributes, int std_in,
1398 int std_out, int std_err, const char *cwd)
1399{
1400 int error = emacs_posix_spawn_init_actions (actions, std_in,
1401 std_out, std_err, cwd);
1402 if (error != 0)
1403 return error;
1404
1405 error = emacs_posix_spawn_init_attributes (attributes);
1406 if (error != 0)
1407 return error;
1408
1409 return 0;
1410}
1411
1412#endif 1392#endif
1413 1393
1414/* Start a new asynchronous subprocess. If successful, return zero 1394/* 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,
1443 if (use_posix_spawn) 1423 if (use_posix_spawn)
1444 { 1424 {
1445 /* Initialize optional attributes before blocking. */ 1425 /* Initialize optional attributes before blocking. */
1446 int error 1426 int error = emacs_posix_spawn_init_actions (&actions, std_in,
1447 = emacs_posix_spawn_init (&actions, &attributes, std_in, 1427 std_out, std_err, cwd);
1448 std_out, std_err, cwd); 1428 if (error != 0)
1429 return error;
1430
1431 error = emacs_posix_spawn_init_attributes (&attributes, oldset);
1449 if (error != 0) 1432 if (error != 0)
1450 return error; 1433 return error;
1451 } 1434 }