From: Carlos O'Donell <carlos@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
libc-alpha@sourceware.org
Cc: Siddhesh Poyarekar <siddhesh@sourceware.org>
Subject: Re: [PATCH v6] posix: Add terminal control setting support for posix_spawn
Date: Mon, 24 Jan 2022 12:25:23 -0500 [thread overview]
Message-ID: <dfdb3000-f5fc-d55b-6325-0548b9b78585@redhat.com> (raw)
In-Reply-To: <20220113143941.816573-1-adhemerval.zanella@linaro.org>
On 1/13/22 09:39, Adhemerval Zanella via Libc-alpha wrote:
> 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.
Please post v7 with changes (and Florian's suggestions).
- NEWS text changes.
- Update dates to 2022.
Agreed, this is a real problem with an identified solution (rather than an abstract API
that we're adding for a future use case).
The fix looks very good to me, and I'm ready to give Reviewed-by and Tested-by once you
post v7 with the fixes for inclusion in glibc 2.35.
> 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.
OK.
> 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).
OK. In general you need an fd (int) and pgrp (pid_t).
> 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);
OK.
>
> 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
> ---
> v6: Rebased against master and added or1k abilist.
> v5: Rebased against master.
> v3: Properly added posix/tst-spawn6 on tests.
> v4: Rebased against master.
> ---
> NEWS | 5 +
> include/unistd.h | 4 +
> posix/Makefile | 6 +-
> posix/Versions | 4 +
> posix/spawn.h | 16 +-
> posix/spawnattr_setflags.c | 3 +-
> posix/spawnattr_tcgetpgrp.c | 26 +++
> posix/spawnattr_tcsetpgrp.c | 26 +++
> posix/tst-spawn6.c | 173 ++++++++++++++++++
> sysdeps/mach/hurd/libhurduser.abilist | 0
> sysdeps/mach/hurd/spawni.c | 13 ++
> sysdeps/mach/libmachuser.abilist | 0
> 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 +
> .../sysv/linux/m68k/coldfire/libc.abilist | 2 +
> .../unix/sysv/linux/m68k/m680x0/libc.abilist | 2 +
> .../sysv/linux/microblaze/be/libc.abilist | 2 +
> .../sysv/linux/microblaze/le/libc.abilist | 2 +
> .../sysv/linux/mips/mips32/fpu/libc.abilist | 2 +
> .../sysv/linux/mips/mips32/nofpu/libc.abilist | 2 +
> .../sysv/linux/mips/mips64/n32/libc.abilist | 2 +
> .../sysv/linux/mips/mips64/n64/libc.abilist | 2 +
> sysdeps/unix/sysv/linux/nios2/libc.abilist | 2 +
> sysdeps/unix/sysv/linux/or1k/libc.abilist | 2 +
> .../linux/powerpc/powerpc32/fpu/libc.abilist | 2 +
> .../powerpc/powerpc32/nofpu/libc.abilist | 2 +
> .../linux/powerpc/powerpc64/be/libc.abilist | 2 +
> .../linux/powerpc/powerpc64/le/libc.abilist | 2 +
> .../unix/sysv/linux/riscv/rv32/libc.abilist | 2 +
> .../unix/sysv/linux/riscv/rv64/libc.abilist | 2 +
> .../unix/sysv/linux/s390/s390-32/libc.abilist | 2 +
> .../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 +
> .../sysv/linux/sparc/sparc32/libc.abilist | 2 +
> .../sysv/linux/sparc/sparc64/libc.abilist | 2 +
> sysdeps/unix/sysv/linux/spawni.c | 11 ++
> sysdeps/unix/sysv/linux/syscalls.list | 2 +-
> .../unix/sysv/linux/x86_64/64/libc.abilist | 2 +
> .../unix/sysv/linux/x86_64/x32/libc.abilist | 2 +
> termios/tcsetpgrp.c | 5 +-
> 49 files changed, 356 insertions(+), 8 deletions(-)
> create mode 100644 posix/spawnattr_tcgetpgrp.c
> create mode 100644 posix/spawnattr_tcsetpgrp.c
> create mode 100644 posix/tst-spawn6.c
> delete mode 100644 sysdeps/mach/hurd/libhurduser.abilist
> delete mode 100644 sysdeps/mach/libmachuser.abilist
>
> diff --git a/NEWS b/NEWS
> index a957b19fdc..0ee67c5f29 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -120,6 +120,11 @@ Major new features:
> The OpenRISC ABI is 32-bit big-endian and uses 64-bit time (y2038 safe) and
> 64-bit file offsets (LFS default).
>
> +* The functions posix_spawnattr_tcsetpgrp_np and posix_spawnattr_tcgetpgrp_np
> + have been added, enabling posix_spawn and posix_spawnp to set the
> + controlling terminal in the new process in a non race manner. These
Change:
s/non race manner/race free manner/g.
> + functions are GNU extensions.
> +
> Deprecated and removed features, and other changes affecting compatibility:
>
> * On x86-64, the LD_PREFER_MAP_32BIT_EXEC environment variable support
> diff --git a/include/unistd.h b/include/unistd.h
> index 2bcdd494e1..6e71d80015 100644
> --- a/include/unistd.h
> +++ b/include/unistd.h
> @@ -183,6 +183,10 @@ extern int __truncate (const char *path, __off_t __length);
> extern void *__sbrk (intptr_t __delta);
> libc_hidden_proto (__sbrk)
>
> +extern int __tcsetpgrp (int fd, __pid_t pgrp);
> +libc_hidden_proto (__tcsetpgrp)
> +extern pid_t __getpgrp (void);
> +libc_hidden_proto (__getpgrp);
Florian noted __getpgrp not used.
>
> /* This variable is set nonzero at startup if the process's effective
> IDs differ from its real IDs, or it is otherwise indicated that
> diff --git a/posix/Makefile b/posix/Makefile
> index 24d8bfd303..6291b1158a 100644
> --- a/posix/Makefile
> +++ b/posix/Makefile
> @@ -64,6 +64,7 @@ routines := \
> spawnattr_getpgroup spawnattr_setpgroup spawn spawnp spawni \
> spawnattr_getsigmask spawnattr_getschedpolicy spawnattr_getschedparam \
> spawnattr_setsigmask spawnattr_setschedpolicy spawnattr_setschedparam \
> + spawnattr_tcgetpgrp spawnattr_tcsetpgrp \
OK. Two additions.
> posix_madvise \
> get_child_max sched_cpucount sched_cpualloc sched_cpufree \
> streams-compat \
> @@ -108,7 +109,7 @@ tests := test-errno tstgetopt testfnm runtests runptests \
> tst-glob-tilde test-ssize-max tst-spawn4 bug-regex37 \
> bug-regex38 tst-regcomp-truncated tst-spawn-chdir \
> tst-wordexp-nocmd tst-execveat tst-spawn5 \
> - tst-sched_getaffinity
> + tst-sched_getaffinity tst-spawn6
OK. tst-spawn6 test.
>
> # Test for the glob symbol version that was replaced in glibc 2.27.
> ifeq ($(have-GLIBC_2.26)$(build-shared),yesyes)
> @@ -287,8 +288,9 @@ tst-exec-ARGS = -- $(host-test-program-cmd)
> tst-exec-static-ARGS = $(tst-exec-ARGS)
> tst-execvpe5-ARGS = -- $(host-test-program-cmd)
> tst-spawn-ARGS = -- $(host-test-program-cmd)
> -tst-spawn-static-ARGS = $(tst-spawn-ARGS)
> tst-spawn5-ARGS = -- $(host-test-program-cmd)
> +tst-spawn-static-ARGS = $(tst-spawn-ARGS)
> +tst-spawn6-ARGS = -- $(host-test-program-cmd)
OK. Though the other line didn't have to move?
> tst-dir-ARGS = `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx)tst-dir
> tst-chmod-ARGS = $(objdir)
> tst-vfork3-ARGS = --test-dir=$(objpfx)
> diff --git a/posix/Versions b/posix/Versions
> index a78792135f..e4f4f649b0 100644
> --- a/posix/Versions
> +++ b/posix/Versions
> @@ -156,6 +156,10 @@ libc {
> execveat;
> posix_spawn_file_actions_addclosefrom_np;
> }
> + GLIBC_2.35 {
> + posix_spawnattr_tcgetpgrp_np;
> + posix_spawnattr_tcsetpgrp_np;
> + }
OK. Two new functions.
> GLIBC_PRIVATE {
> __libc_fork; __libc_pread; __libc_pwrite;
> __nanosleep_nocancel; __pause_nocancel;
> diff --git a/posix/spawn.h b/posix/spawn.h
> index 58f17d1277..7779020250 100644
> --- a/posix/spawn.h
> +++ b/posix/spawn.h
> @@ -34,7 +34,8 @@ typedef struct
> sigset_t __ss;
> struct sched_param __sp;
> int __policy;
> - int __pad[16];
> + int __ctty_fd;
> + int __pad[15];
OK. Add the fd.
> } posix_spawnattr_t;
>
>
> @@ -59,6 +60,7 @@ typedef struct
> #ifdef __USE_GNU
> # define POSIX_SPAWN_USEVFORK 0x40
> # define POSIX_SPAWN_SETSID 0x80
> +# define POSIX_SPAWN_TCSETPGROUP 0x100
OK. Consume another flag.
> #endif
>
>
> @@ -166,6 +168,18 @@ extern int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr,
> __restrict __schedparam)
> __THROW __nonnull ((1, 2));
>
> +#ifdef __USE_GNU
> +/* Make the spawned process the foreground process group on the terminal
> + associated with FD (which must be a controlling terminal, and still be
> + associated with its session). */
> +extern int posix_spawnattr_tcsetpgrp_np (posix_spawnattr_t *__attr, int fd)
> + __THROW __nonnull ((1));
OK. First arg non-null.
> +
> +/* Return the associated terminal FD in the attribute structure. */
> +extern int posix_spawnattr_tcgetpgrp_np (const posix_spawnattr_t *
> + __restrict __attr, int *fd)
> + __THROW __nonnull ((1, 2));
OK. First and second args non-null.
> +#endif
>
> /* Initialize data structure for file attribute for `spawn' call. */
> extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *
> diff --git a/posix/spawnattr_setflags.c b/posix/spawnattr_setflags.c
> index 3e6fe4ef03..603bfcf911 100644
> --- a/posix/spawnattr_setflags.c
> +++ b/posix/spawnattr_setflags.c
> @@ -26,7 +26,8 @@
> | POSIX_SPAWN_SETSCHEDPARAM \
> | POSIX_SPAWN_SETSCHEDULER \
> | POSIX_SPAWN_SETSID \
> - | POSIX_SPAWN_USEVFORK)
> + | POSIX_SPAWN_USEVFORK \
> + | POSIX_SPAWN_TCSETPGROUP)
OK.
>
> /* Store flags in the attribute structure. */
> int
> diff --git a/posix/spawnattr_tcgetpgrp.c b/posix/spawnattr_tcgetpgrp.c
> new file mode 100644
> index 0000000000..2c037b21b5
> --- /dev/null
> +++ b/posix/spawnattr_tcgetpgrp.c
> @@ -0,0 +1,26 @@
> +/* Get the controlling terminal option.
> + Copyright (C) 2021 Free Software Foundation, Inc.
Wrong date.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <spawn.h>
> +
> +int
> +posix_spawnattr_tcgetpgrp_np (const posix_spawnattr_t *attr, int *fd)
> +{
> + *fd = attr->__ctty_fd;
> + return 0;
OK.
> +}
> diff --git a/posix/spawnattr_tcsetpgrp.c b/posix/spawnattr_tcsetpgrp.c
> new file mode 100644
> index 0000000000..b1b5d5dba0
> --- /dev/null
> +++ b/posix/spawnattr_tcsetpgrp.c
> @@ -0,0 +1,26 @@
> +/* Set the controlling terminal option.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <spawn.h>
> +
> +int
> +posix_spawnattr_tcsetpgrp_np (posix_spawnattr_t *attr, int fd)
> +{
> + attr->__ctty_fd = fd;
> + return 0;
> +}
OK.
> diff --git a/posix/tst-spawn6.c b/posix/tst-spawn6.c
> new file mode 100644
> index 0000000000..e3abb0f945
> --- /dev/null
> +++ b/posix/tst-spawn6.c
> @@ -0,0 +1,173 @@
> +/* Check posix_spawn set controlling terminal extension.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <getopt.h>
> +#include <intprops.h>
> +#include <paths.h>
> +#include <spawn.h>
> +#include <stdbool.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <support/check.h>
> +#include <support/xunistd.h>
> +#include <sys/wait.h>
> +
> +static int
> +handle_restart (const char *argv1)
> +{
> + int fd = xopen (_PATH_TTY, O_RDONLY, 0600);
> +
> + /* If process group is not changed (POSIX_SPAWN_SETPGROUP), then check
> + the creating process one, otherwise check against the process group
> + itself. */
> + pid_t pgrp;
> + if (strcmp (argv1, "setgrpr") != 0)
> + TEST_COMPARE (sscanf (argv1, "%d", &pgrp), 1);
> + else
> + {
> + pgrp = getpgrp ();
> + /* Check if a new process group was actually created. */
> + pid_t ppid = getppid ();
> + pid_t pgid = getpgid (ppid);
> + TEST_VERIFY (pgid != pgrp);
> + }
> +
> + TEST_COMPARE (tcgetpgrp (fd), pgrp);
> +
> + xclose (fd);
> + return 0;
> +}
> +
> +static int restart;
> +#define CMDLINE_OPTIONS \
> + { "restart", no_argument, &restart, 1 },
> +
> +static void
> +run_subprogram (int argc, char *argv[], const posix_spawnattr_t *attr,
> + int exp_err)
> +{
> + short int flags;
> + TEST_COMPARE (posix_spawnattr_getflags (attr, &flags), 0);
> + bool setpgrp = flags & POSIX_SPAWN_SETPGROUP;
OK.
> +
> + char *spargv[9];
> + char pgrp[INT_STRLEN_BOUND (pid_t)];
> +
> + int i = 0;
> + for (; i < argc - 1; i++)
> + spargv[i] = argv[i + 1];
> + spargv[i++] = (char *) "--direct";
> + spargv[i++] = (char *) "--restart";
> + if (setpgrp)
> + spargv[i++] = (char *) "setgrpr";
> + else
> + {
> + snprintf (pgrp, sizeof pgrp, "%d", getpgrp ());
> + spargv[i++] = pgrp;
> + }
> + spargv[i] = NULL;
> +
> + pid_t pid;
> + TEST_COMPARE (posix_spawn (&pid, argv[1], NULL, attr, spargv, environ),
> + exp_err);
> + if (exp_err != 0)
> + return;
> +
> + int status;
> + TEST_COMPARE (xwaitpid (pid, &status, WUNTRACED), pid);
> + TEST_VERIFY (WIFEXITED (status));
> + TEST_VERIFY (!WIFSTOPPED (status));
> + TEST_VERIFY (!WIFSIGNALED (status));
> + TEST_COMPARE (WEXITSTATUS (status), 0);
> +}
> +
> +static int
> +do_test (int argc, char *argv[])
> +{
> + /* We must have either:
> + - One our fource parameters left if called initially:
Suggest:
- Four parameters left if called initially:
> + + path to ld.so optional
> + + "--library-path" optional
> + + the library path optional
> + + the application name
> + - six parameters left if called through re-execution:
> + + --setgrpr optional
> + */
> +
> + if (restart)
> + return handle_restart (argv[1]);
> +
> + int tcfd = xopen (_PATH_TTY, O_RDONLY, 0600);
> +
> + /* Check getters and setters. */
> + {
> + posix_spawnattr_t attr;
> + TEST_COMPARE (posix_spawnattr_init (&attr), 0);
> + TEST_COMPARE (posix_spawnattr_tcsetpgrp_np (&attr, tcfd), 0);
OK. Set.
> +
> + int fd;
> + TEST_COMPARE (posix_spawnattr_tcgetpgrp_np (&attr, &fd), 0);
> + TEST_COMPARE (tcfd, fd);
OK. Get and compare.
> + }
> +
> + /* Check setting the controlling terminal without changing the group. */
> + {
> + posix_spawnattr_t attr;
> + TEST_COMPARE (posix_spawnattr_init (&attr), 0);
> + TEST_COMPARE (posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP),
> + 0);
> + TEST_COMPARE (posix_spawnattr_tcsetpgrp_np (&attr, tcfd), 0);
> +
> + run_subprogram (argc, argv, &attr, 0);
OK. exp_err is 0, so it should run, and not change the pgrp.
> + }
> +
> + /* Check setting both the controlling terminal and the create a new process
> + group. */
> + {
> + posix_spawnattr_t attr;
> + TEST_COMPARE (posix_spawnattr_init (&attr), 0);
> + TEST_COMPARE (posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP
> + | POSIX_SPAWN_SETPGROUP),
> + 0);
> + TEST_COMPARE (posix_spawnattr_setpgroup (&attr, 0), 0);
> + TEST_COMPARE (posix_spawnattr_tcsetpgrp_np (&attr, tcfd), 0);
OK. Doing both.
> +
> + run_subprogram (argc, argv, &attr, 0);
OK.
> + }
> +
> + /* Trying to set the controlling terminal after a setsid() incurs in a ENOTTY
> + from tcsetpgrp. */
> + {
> + posix_spawnattr_t attr;
> + TEST_COMPARE (posix_spawnattr_init (&attr), 0);
> + TEST_COMPARE (posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP
> + | POSIX_SPAWN_SETSID), 0);
> + TEST_COMPARE (posix_spawnattr_tcsetpgrp_np (&attr, tcfd), 0);
> +
> + run_subprogram (argc, argv, &attr, ENOTTY);
OK. exp_err is ENOTTY. Good check.
> + }
> +
> + xclose (tcfd);
> +
> + return 0;
> +}
> +
> +#define TEST_FUNCTION_ARGV do_test
> +#include <support/test-driver.c>
> diff --git a/sysdeps/mach/hurd/libhurduser.abilist b/sysdeps/mach/hurd/libhurduser.abilist
> deleted file mode 100644
> index e69de29bb2..0000000000
> diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c
> index ebf2b5e27f..bccdd013bf 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)
OK. Good, check for previous error otherwise try to do this.
> + {
> + 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);
OK. Set the pgrp... then...
> + if (!err)
> + err = __tcsetpgrp (attrp->__ctty_fd, pgrp);
OK. Call tcsetpgrp with fd and pgrp.
OK. Err is set and exposed with earlier errors not being overriden.
> + }
> +
> /* Set the effective user and group IDs. */
> if (!err && (flags & POSIX_SPAWN_RESETIDS) != 0)
> {
> diff --git a/sysdeps/mach/libmachuser.abilist b/sysdeps/mach/libmachuser.abilist
> deleted file mode 100644
> index e69de29bb2..0000000000
> diff --git a/sysdeps/unix/bsd/tcsetpgrp.c b/sysdeps/unix/bsd/tcsetpgrp.c
> index a7c34ae8d5..272f207c3d 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)
OK.
> {
> 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 fed942ed4b..67300eb86a 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> @@ -2614,3 +2614,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 2867932704..3aee0b5cc0 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> @@ -2711,6 +2711,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 239db7bab0..633ac44852 100644
> --- a/sysdeps/unix/sysv/linux/arc/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
> @@ -2375,3 +2375,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 bc79dcfe8a..40bd490a47 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -493,6 +493,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 614607fd6b..eaecc3a2c4 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -490,6 +490,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 2b61543f0d..1ca0677a9d 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2649,3 +2649,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 6b3cb1adb4..8a7fb90c6b 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2598,6 +2598,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 7f608c1b64..c2bfceb01e 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2782,6 +2782,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 865deec43f..16a8b3f141 100644
> --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> @@ -2549,6 +2549,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 a172d74632..ed03495796 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> @@ -494,6 +494,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 174e9c7739..d69aac0863 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2725,6 +2725,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 d042be1369..14e96a0d09 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2698,3 +2698,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 332da62de2..32176ecc85 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2695,3 +2695,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 2d6ec0d0e8..6382e8fd4f 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2690,6 +2690,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 6c5befa72b..6f1ea0edd0 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2688,6 +2688,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 5fb24c97e1..a07f0b558c 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2696,6 +2696,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 f4f29fc15e..33be3c6545 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> @@ -2600,6 +2600,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 2e7300cd05..cd150f8e86 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> @@ -2737,3 +2737,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 eea4e3dc3f..04a888a296 100644
> --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist
> @@ -1394,6 +1394,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 129a2f16a7..ca95ab708f 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -2752,6 +2752,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 7e23226779..e2a5b871ba 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -2785,6 +2785,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 6f97392b70..ae343bfc69 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> @@ -2508,6 +2508,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 29058a041a..e2a94dca60 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> @@ -2810,3 +2810,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 d2924766d2..fed2375d8e 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> @@ -2377,3 +2377,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 b770e05da3..cfa0be4ea2 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> @@ -2577,3 +2577,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 bed3433a2b..74af810cb1 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -2750,6 +2750,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 4f1a143da5..066ad16f19 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> @@ -2545,6 +2545,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 92c8dec8ec..a096cf3e2b 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2605,6 +2605,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 263da58cb7..89ad4c54e9 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2602,6 +2602,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 0171efe7db..bcd2bd2b76 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -2745,6 +2745,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 7f8d45f362..b9db516d26 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> @@ -2572,6 +2572,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 4c2d4195cd..93359c708b 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)
OK. Both operations in one.
> + 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/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
> index c93c0d8193..3a21af8a4d 100644
> --- a/sysdeps/unix/sysv/linux/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/syscalls.list
> @@ -17,7 +17,7 @@ getpid - getpid Ei: __getpid getpid
> getegid - getegid Ei: __getegid getegid
> geteuid - geteuid Ei: __geteuid geteuid
> getpgid - getpgid i:i __getpgid getpgid
> -getpgrp - getpgrp Ei: getpgrp
> +getpgrp - getpgrp Ei: __getpgrp getpgrp
OK. Adding alias.
> getppid - getppid Ei: __getppid getppid
> getresuid - getresuid i:ppp getresuid
> getresgid - getresgid i:ppp getresgid
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> index c2f1a8ecc6..6876db985b 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> @@ -2523,6 +2523,8 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object 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 8b43acf100..5cb17d8c82 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> @@ -2629,3 +2629,5 @@ GLIBC_2.34 tss_get F
> GLIBC_2.34 tss_set F
> GLIBC_2.35 __memcmpeq F
> GLIBC_2.35 _dl_find_object F
> +GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
> +GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
> diff --git a/termios/tcsetpgrp.c b/termios/tcsetpgrp.c
> index 581328b12a..1e4ff0987d 100644
> --- a/termios/tcsetpgrp.c
> +++ b/termios/tcsetpgrp.c
> @@ -21,7 +21,7 @@
>
> /* 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)
OK.
> {
> if (fd < 0)
> {
> @@ -32,6 +32,7 @@ tcsetpgrp (int fd, pid_t pgrp_id)
> __set_errno (ENOSYS);
> return -1;
> }
> -
> +weak_alias (__tcsetpgrp, tcsetpgrp);
> +libc_hidden_def (__tcsetpgrp)
OK.
>
> stub_warning (tcsetpgrp)
--
Cheers,
Carlos.
next prev parent reply other threads:[~2022-01-24 17:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 14:39 Adhemerval Zanella
2022-01-13 15:03 ` Florian Weimer
2022-01-13 17:21 ` Adhemerval Zanella
2022-01-24 17:25 ` Carlos O'Donell [this message]
2022-01-24 17:48 ` Adhemerval Zanella
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dfdb3000-f5fc-d55b-6325-0548b9b78585@redhat.com \
--to=carlos@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=siddhesh@sourceware.org \
/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.
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).