From 342cc934a3bf74ac618e2318d738f22ac93257ba Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 14 Jun 2021 14:41:31 -0300 Subject: posix: Add terminal control setting support for posix_spawn Currently there is no proper way to set the controlling terminal through posix_spawn in race free manner [1]. This forces shell implementations to keep using fork+exec when launching background process groups, even when using posix_spawn yields better performance. This patch adds a new GNU extension so the creating process can configure the created process terminal group. This is done with a new flag, POSIX_SPAWN_TCSETPGROUP, along with two new attribute functions: posix_spawnattr_tcsetpgrp_np, and posix_spawnattr_tcgetpgrp_np. The function sets a new attribute, spawn-tcgroupfd, that references to the controlling terminal. The controlling terminal is set after the spawn-pgroup attribute, and uses the spawn-tcgroupfd along with current creating process group (so it is composable with POSIX_SPAWN_SETPGROUP). To create a process and set the controlling terminal, one can use the following sequence: posix_spawnattr_t attr; posix_spawnattr_init (&attr); posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP); posix_spawnattr_tcsetpgrp_np (&attr, tcfd); If the idea is also to create a new process groups: posix_spawnattr_t attr; posix_spawnattr_init (&attr); posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP | POSIX_SPAWN_SETPGROUP); posix_spawnattr_tcsetpgrp_np (&attr, tcfd); posix_spawnattr_setpgroup (&attr, 0); The controlling terminal file descriptor is ignored if the new flag is not set. This interface is slight different than the one provided by QNX [2], which only provides the POSIX_SPAWN_TCSETPGROUP flag. The QNX documentation does not specify how the controlling terminal is obtained nor how it iteracts with POSIX_SPAWN_SETPGROUP. Since a glibc implementation is library based, it is more straightforward and avoid requires additional file descriptor operations to request the caller to setup the controlling terminal file descriptor (and it also allows a bit less error handling by posix_spawn). Checked on x86_64-linux-gnu and i686-linux-gnu. [1] https://github.com/ksh93/ksh/issues/79 [2] https://www.qnx.com/developers/docs/7.0.0/index.html#com.qnx.doc.neutrino.lib_ref/topic/p/posix_spawn.html Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- sysdeps/mach/hurd/spawni.c | 13 +++++++++++++ sysdeps/unix/bsd/tcsetpgrp.c | 4 +++- sysdeps/unix/sysv/linux/aarch64/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/alpha/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/arc/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/arm/be/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/arm/le/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/csky/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/hppa/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/i386/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/ia64/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/microblaze/be/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/microblaze/le/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/nios2/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/or1k/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 2 ++ .../unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/sh/be/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/sh/le/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/spawni.c | 11 +++++++++++ sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 2 ++ 36 files changed, 93 insertions(+), 1 deletion(-) (limited to 'sysdeps') diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c index ebf2b5e..bccdd01 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/spawni.c @@ -390,6 +390,19 @@ retry: if (!err && (flags & POSIX_SPAWN_SETPGROUP) != 0) err = __proc_setpgrp (proc, new_pid, attrp->__pgrp); + /* Set the controlling terminal. */ + if (!err && (flags & POSIX_SPAWN_TCSETPGROUP) != 0) + { + pid_t pgrp; + /* Check if it is possible to avoid an extra syscall. */ + if ((attrp->__flags & POSIX_SPAWN_SETPGROUP) != 0 && attrp->__pgrp != 0) + pgrp = attrp->__pgrp; + else + err = __proc_getpgrp (proc, new_pid, &pgrp); + if (!err) + err = __tcsetpgrp (attrp->__ctty_fd, pgrp); + } + /* Set the effective user and group IDs. */ if (!err && (flags & POSIX_SPAWN_RESETIDS) != 0) { diff --git a/sysdeps/unix/bsd/tcsetpgrp.c b/sysdeps/unix/bsd/tcsetpgrp.c index a7c34ae..272f207 100644 --- a/sysdeps/unix/bsd/tcsetpgrp.c +++ b/sysdeps/unix/bsd/tcsetpgrp.c @@ -22,7 +22,9 @@ /* Set the foreground process group ID of FD set PGRP_ID. */ int -tcsetpgrp (int fd, pid_t pgrp_id) +__tcsetpgrp (int fd, pid_t pgrp_id) { return __ioctl (fd, TIOCSPGRP, &pgrp_id); } +weak_alias (__tcsetpgrp, tcsetpgrp) +libc_hidden_def (__tcsetpgrp) diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index c1a5ee9..9dd574d 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2615,3 +2615,5 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 1a30d06..f667048 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2712,6 +2712,8 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_sprintf F diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist index e5dfdab..97aa3da 100644 --- a/sysdeps/unix/sysv/linux/arc/libc.abilist +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -2376,3 +2376,5 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index 4d3fd87..18f4364 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -495,6 +495,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index 009dc9d..2c12c02 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -492,6 +492,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist index df8da50..7f28516 100644 --- a/sysdeps/unix/sysv/linux/csky/libc.abilist +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2651,3 +2651,5 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index 7ea1b01..9776f20 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2600,6 +2600,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 99ccf35..96b50d0 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2784,6 +2784,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist index 201542d..9b2eebf 100644 --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -2550,6 +2550,8 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 32fd72a..71cd354 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -496,6 +496,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0x98 GLIBC_2.4 _IO_2_1_stdin_ D 0x98 diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index d26f0ae..ced01a5 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2727,6 +2727,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index 520ca08..5406c01 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2700,3 +2700,5 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist index 9162c31..53b8ade 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -2697,3 +2697,5 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index 656fdbd..919973e 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2692,6 +2692,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 5f0b90d..cf5a8dc 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -2690,6 +2690,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 9f4891f..003c3bd 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2698,6 +2698,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index f1b0644..73629c2 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -2601,6 +2601,8 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist index 1cf88e3..9e8645e 100644 --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2739,3 +2739,5 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist index ac2a828..7ed49ee 100644 --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist @@ -1395,6 +1395,8 @@ GLIBC_2.35 posix_spawnattr_setschedparam F GLIBC_2.35 posix_spawnattr_setschedpolicy F GLIBC_2.35 posix_spawnattr_setsigdefault F GLIBC_2.35 posix_spawnattr_setsigmask F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.35 posix_spawnp F GLIBC_2.35 ppoll F GLIBC_2.35 prctl F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index 9692335..3d1ba98 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -2754,6 +2754,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_sprintf F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index 7da0ed5..d979a3b 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -2787,6 +2787,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_sprintf F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index 72cf685..44688e5 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -2509,6 +2509,8 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_sprintf F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index ee7f67f..4068271 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -2811,3 +2811,5 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist index b8c0854..e239d62 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist @@ -2378,3 +2378,5 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index 90f331f..ab0c4e7 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2578,3 +2578,5 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index ded5e3c..74e3a46 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2752,6 +2752,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_sprintf F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 4b262992..e5553f0 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -2546,6 +2546,8 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_sprintf F diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index 8bfd716..9662041 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2607,6 +2607,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index 47fd204..bf90e92 100644 --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2604,6 +2604,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 9b82f15..ddb0d06 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -2747,6 +2747,8 @@ GLIBC_2.35 __epoll_pwait2_time64 F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_sprintf F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index 94caf01..ca14224 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -2573,6 +2573,8 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c index 4c2d419..93359c7 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/spawni.c @@ -164,6 +164,17 @@ __spawni_child (void *arguments) && __setpgid (0, attr->__pgrp) != 0) goto fail; + /* Set the controlling terminal. */ + if ((attr->__flags & POSIX_SPAWN_TCSETPGROUP) != 0) + { + /* Check if it is possible to avoid an extra syscall. */ + pid_t pgrp = (attr->__flags & POSIX_SPAWN_SETPGROUP) != 0 + && attr->__pgrp != 0 + ? attr->__pgrp : __getpgid (0); + if (__tcsetpgrp (attr->__ctty_fd, pgrp) != 0) + goto fail; + } + /* Set the effective user and group IDs. */ if ((attr->__flags & POSIX_SPAWN_RESETIDS) != 0 && (local_seteuid (__getuid ()) != 0 diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index 140e9e8..661d928 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -2524,6 +2524,8 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 04d13ce..bb8058d 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2630,3 +2630,5 @@ GLIBC_2.34 tss_set F GLIBC_2.35 __memcmpeq F GLIBC_2.35 _dl_find_object F GLIBC_2.35 epoll_pwait2 F +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F -- cgit v1.1