diff mbox series

posix: Replace posix_spawnattr_tc{get, set}pgrp_np with posix_spawn_file_actions_addtcsetpgrp_np

Message ID 20220127141400.3364940-1-adhemerval.zanella@linaro.org
State Superseded
Headers show
Series posix: Replace posix_spawnattr_tc{get, set}pgrp_np with posix_spawn_file_actions_addtcsetpgrp_np | expand

Checks

Context Check Description
dj/TryBot-apply_patch fail Patch failed to apply to master at the time it was sent
dj/TryBot-32bit fail Patch series failed to apply

Commit Message

Adhemerval Zanella Jan. 27, 2022, 2:14 p.m. UTC
The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
controlling terminal), so it would make more sense to actually fit
it on the file actions API.

Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
implicit by the presence of tcsetpgrp file action.

The posix/tst-spawn6.c is also fixed when TTY can is not present.

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 NEWS                                          |  7 +-
 posix/Makefile                                |  2 +-
 posix/Versions                                |  3 +-
 posix/spawn.h                                 | 24 ++----
 posix/spawn_faction_addtcsetpgrp_np.c         | 50 +++++++++++
 posix/spawn_faction_destroy.c                 |  1 +
 posix/spawn_int.h                             |  5 ++
 posix/spawnattr_setflags.c                    |  3 +-
 posix/spawnattr_tcgetpgrp.c                   | 26 ------
 posix/spawnattr_tcsetpgrp.c                   | 26 ------
 posix/tst-spawn6.c                            | 83 ++++++++++++-------
 sysdeps/mach/hurd/i386/libc.abilist           |  1 +
 sysdeps/mach/hurd/spawni.c                    | 26 +++---
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |  3 +-
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |  3 +-
 sysdeps/unix/sysv/linux/arc/libc.abilist      |  3 +-
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  3 +-
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  3 +-
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  3 +-
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  3 +-
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  3 +-
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |  3 +-
 .../sysv/linux/m68k/coldfire/libc.abilist     |  3 +-
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  3 +-
 .../sysv/linux/microblaze/be/libc.abilist     |  3 +-
 .../sysv/linux/microblaze/le/libc.abilist     |  3 +-
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  3 +-
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  3 +-
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  3 +-
 .../sysv/linux/mips/mips64/n64/libc.abilist   |  3 +-
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  3 +-
 sysdeps/unix/sysv/linux/or1k/libc.abilist     |  3 +-
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  3 +-
 .../powerpc/powerpc32/nofpu/libc.abilist      |  3 +-
 .../linux/powerpc/powerpc64/be/libc.abilist   |  3 +-
 .../linux/powerpc/powerpc64/le/libc.abilist   |  3 +-
 .../unix/sysv/linux/riscv/rv32/libc.abilist   |  3 +-
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |  3 +-
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  3 +-
 .../unix/sysv/linux/s390/s390-64/libc.abilist |  3 +-
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  3 +-
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  3 +-
 .../sysv/linux/sparc/sparc32/libc.abilist     |  3 +-
 .../sysv/linux/sparc/sparc64/libc.abilist     |  3 +-
 sysdeps/unix/sysv/linux/spawni.c              | 21 +++--
 .../unix/sysv/linux/x86_64/64/libc.abilist    |  3 +-
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |  3 +-
 47 files changed, 182 insertions(+), 195 deletions(-)
 create mode 100644 posix/spawn_faction_addtcsetpgrp_np.c
 delete mode 100644 posix/spawnattr_tcgetpgrp.c
 delete mode 100644 posix/spawnattr_tcsetpgrp.c

Comments

Florian Weimer Jan. 27, 2022, 4:11 p.m. UTC | #1
* Adhemerval Zanella:

> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
> controlling terminal), so it would make more sense to actually fit
> it on the file actions API.
>
> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
> implicit by the presence of tcsetpgrp file action.
>
> The posix/tst-spawn6.c is also fixed when TTY can is not present.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.

This has an ABI check failure on Hurd:

--- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
+++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
@@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
-GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
-GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F

The changes look okay to me.  A second review is probably warranted at
this stage.

Thanks,
Florian
Adhemerval Zanella Jan. 27, 2022, 5:04 p.m. UTC | #2
On 27/01/2022 13:11, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
>> controlling terminal), so it would make more sense to actually fit
>> it on the file actions API.
>>
>> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
>> implicit by the presence of tcsetpgrp file action.
>>
>> The posix/tst-spawn6.c is also fixed when TTY can is not present.
>>
>> Checked on x86_64-linux-gnu and i686-linux-gnu.
> 
> This has an ABI check failure on Hurd:
> 
> --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
> +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
> @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
> -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
> -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
> 
> The changes look okay to me.  A second review is probably warranted at
> this stage.

Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
and requires manual edit to get it right.
Samuel Thibault Jan. 27, 2022, 5:15 p.m. UTC | #3
Hello,

Adhemerval Zanella via Libc-alpha, le jeu. 27 janv. 2022 14:04:28 -0300, a ecrit:
> On 27/01/2022 13:11, Florian Weimer wrote:
> > * Adhemerval Zanella:
> > 
> >> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
> >> controlling terminal), so it would make more sense to actually fit
> >> it on the file actions API.
> >>
> >> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
> >> implicit by the presence of tcsetpgrp file action.
> >>
> >> The posix/tst-spawn6.c is also fixed when TTY can is not present.
> >>
> >> Checked on x86_64-linux-gnu and i686-linux-gnu.
> > 
> > This has an ABI check failure on Hurd:
> > 
> > --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
> > +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
> > @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
> > -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
> > -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
> > 
> > The changes look okay to me.  A second review is probably warranted at
> > this stage.
> 
> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
> and requires manual edit to get it right.

I don't think I understand.  How is it different in the linux case?

Samuel
Adhemerval Zanella Jan. 27, 2022, 6:09 p.m. UTC | #4
On 27/01/2022 14:15, Samuel Thibault wrote:
> Hello,
> 
> Adhemerval Zanella via Libc-alpha, le jeu. 27 janv. 2022 14:04:28 -0300, a ecrit:
>> On 27/01/2022 13:11, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
>>>> controlling terminal), so it would make more sense to actually fit
>>>> it on the file actions API.
>>>>
>>>> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
>>>> implicit by the presence of tcsetpgrp file action.
>>>>
>>>> The posix/tst-spawn6.c is also fixed when TTY can is not present.
>>>>
>>>> Checked on x86_64-linux-gnu and i686-linux-gnu.
>>>
>>> This has an ABI check failure on Hurd:
>>>
>>> --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
>>> +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
>>> @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
>>> -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
>>> -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
>>>
>>> The changes look okay to me.  A second review is probably warranted at
>>> this stage.
>>
>> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
>> and requires manual edit to get it right.
> 
> I don't think I understand.  How is it different in the linux case?

A 'make update-abi' with a default 'configure --prefix=/usr' creates two
files on source:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   sysdeps/mach/hurd/i386/libc.abilist
        modified:   sysdeps/mach/hurd/libhurduser.abilist
        modified:   sysdeps/mach/libmachuser.abilist

And the libc.abilist is jsut annoying by the fact Hurd seems to use a different
default path than Linux ports (which generates an _nl_default_dirname with
different size).

Am I doing something wrong with the Hurd build?
Samuel Thibault Jan. 27, 2022, 6:10 p.m. UTC | #5
Adhemerval Zanella, le jeu. 27 janv. 2022 15:09:29 -0300, a ecrit:
> 
> 
> On 27/01/2022 14:15, Samuel Thibault wrote:
> > Hello,
> > 
> > Adhemerval Zanella via Libc-alpha, le jeu. 27 janv. 2022 14:04:28 -0300, a ecrit:
> >> On 27/01/2022 13:11, Florian Weimer wrote:
> >>> * Adhemerval Zanella:
> >>>
> >>>> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
> >>>> controlling terminal), so it would make more sense to actually fit
> >>>> it on the file actions API.
> >>>>
> >>>> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
> >>>> implicit by the presence of tcsetpgrp file action.
> >>>>
> >>>> The posix/tst-spawn6.c is also fixed when TTY can is not present.
> >>>>
> >>>> Checked on x86_64-linux-gnu and i686-linux-gnu.
> >>>
> >>> This has an ABI check failure on Hurd:
> >>>
> >>> --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
> >>> +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
> >>> @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
> >>> -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
> >>> -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
> >>>
> >>> The changes look okay to me.  A second review is probably warranted at
> >>> this stage.
> >>
> >> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
> >> and requires manual edit to get it right.
> > 
> > I don't think I understand.  How is it different in the linux case?
> 
> A 'make update-abi' with a default 'configure --prefix=/usr' creates two
> files on source:
> 
> $ git status
> On branch master
> Your branch is up to date with 'origin/master'.
> 
> Changes not staged for commit:
>   (use "git add <file>..." to update what will be committed)
>   (use "git restore <file>..." to discard changes in working directory)
>         modified:   sysdeps/mach/hurd/i386/libc.abilist
>         modified:   sysdeps/mach/hurd/libhurduser.abilist
>         modified:   sysdeps/mach/libmachuser.abilist
> 
> And the libc.abilist is jsut annoying by the fact Hurd seems to use a different
> default path than Linux ports (which generates an _nl_default_dirname with
> different size).
> 
> Am I doing something wrong with the Hurd build?

Probably not, I didn't even know about the update-abi target.

Samuel
Florian Weimer Jan. 27, 2022, 6:12 p.m. UTC | #6
* Adhemerval Zanella:

> On 27/01/2022 14:15, Samuel Thibault wrote:
>> Hello,
>> 
>> Adhemerval Zanella via Libc-alpha, le jeu. 27 janv. 2022 14:04:28 -0300, a ecrit:
>>> On 27/01/2022 13:11, Florian Weimer wrote:
>>>> * Adhemerval Zanella:
>>>>
>>>>> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
>>>>> controlling terminal), so it would make more sense to actually fit
>>>>> it on the file actions API.
>>>>>
>>>>> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
>>>>> implicit by the presence of tcsetpgrp file action.
>>>>>
>>>>> The posix/tst-spawn6.c is also fixed when TTY can is not present.
>>>>>
>>>>> Checked on x86_64-linux-gnu and i686-linux-gnu.
>>>>
>>>> This has an ABI check failure on Hurd:
>>>>
>>>> --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
>>>> +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
>>>> @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
>>>> -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
>>>> -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
>>>>
>>>> The changes look okay to me.  A second review is probably warranted at
>>>> this stage.
>>>
>>> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
>>> and requires manual edit to get it right.
>> 
>> I don't think I understand.  How is it different in the linux case?
>
> A 'make update-abi' with a default 'configure --prefix=/usr' creates two
> files on source:

I've never seen this when using “make update-all-abi” from an x86
build.

Thanks,
Florian
Samuel Thibault Jan. 28, 2022, 12:07 a.m. UTC | #7
Adhemerval Zanella, le jeu. 27 janv. 2022 15:09:29 -0300, a ecrit:
> On 27/01/2022 14:15, Samuel Thibault wrote:
> > Adhemerval Zanella via Libc-alpha, le jeu. 27 janv. 2022 14:04:28 -0300, a ecrit:
> >> On 27/01/2022 13:11, Florian Weimer wrote:
> >>> * Adhemerval Zanella:
> >>>
> >>>> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
> >>>> controlling terminal), so it would make more sense to actually fit
> >>>> it on the file actions API.
> >>>>
> >>>> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
> >>>> implicit by the presence of tcsetpgrp file action.
> >>>>
> >>>> The posix/tst-spawn6.c is also fixed when TTY can is not present.
> >>>>
> >>>> Checked on x86_64-linux-gnu and i686-linux-gnu.
> >>>
> >>> This has an ABI check failure on Hurd:
> >>>
> >>> --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
> >>> +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
> >>> @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
> >>> -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
> >>> -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
> >>>
> >>> The changes look okay to me.  A second review is probably warranted at
> >>> this stage.
> >>
> >> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
> >> and requires manual edit to get it right.
> > 
> > I don't think I understand.  How is it different in the linux case?
> 
> A 'make update-abi' with a default 'configure --prefix=/usr' creates two
> files on source:

>         modified:   sysdeps/mach/hurd/libhurduser.abilist
>         modified:   sysdeps/mach/libmachuser.abilist

Ok, would the attached patch be ok? We do not track ABI on these libs.

>         modified:   sysdeps/mach/hurd/i386/libc.abilist
> 
> And the libc.abilist is jsut annoying by the fact Hurd seems to use a different
> default path than Linux ports (which generates an _nl_default_dirname with
> different size).
> 
> Am I doing something wrong with the Hurd build?

Actually on the Hurd there is not supposed to be a /usr, so ./configure
should be passed --prefix=/

Thanks for raising the issue,
Samuel
diff --git a/sysdeps/mach/Makefile b/sysdeps/mach/Makefile
index 83d0e03ab3..b1f87e39eb 100644
--- a/sysdeps/mach/Makefile
+++ b/sysdeps/mach/Makefile
@@ -74,4 +74,9 @@ endif
 
 LDLIBS-pthread.so += $(objdir)/mach/libmachuser.so
 
+ifeq (mach,$(subdir))
+update-abi-libmachuser:
+	@:
+endif
+
 endif	# in-Makerules
diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile
index 356bddde80..829207665c 100644
--- a/sysdeps/mach/hurd/Makefile
+++ b/sysdeps/mach/hurd/Makefile
@@ -226,4 +226,9 @@ endif
 LDLIBS-pthread.so += $(objdir)/hurd/libhurduser.so
 LDLIBS-c_malloc_debug.so += $(link-rpcuserlibs)
 
+ifeq (hurd,$(subdir))
+update-abi-libhurduser:
+	@:
+endif
+
 endif	# in-Makerules
H.J. Lu Jan. 29, 2022, 4:55 a.m. UTC | #8
On Thu, Jan 27, 2022 at 9:05 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
>
>
> On 27/01/2022 13:11, Florian Weimer wrote:
> > * Adhemerval Zanella:
> >
> >> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
> >> controlling terminal), so it would make more sense to actually fit
> >> it on the file actions API.
> >>
> >> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
> >> implicit by the presence of tcsetpgrp file action.
> >>
> >> The posix/tst-spawn6.c is also fixed when TTY can is not present.

I still got

[hjl@gnu-tgl-2 build-x86_64-linux]$ cat posix/tst-spawn6.out
error: xopen.c:28: open64 ("/dev/tty", 0x0, 0600): No such device or address
error: 1 test failures
[hjl@gnu-tgl-2 build-x86_64-linux]$

It happened when I did

$ nohup make check&
$ logout

> >> Checked on x86_64-linux-gnu and i686-linux-gnu.
> >
> > This has an ABI check failure on Hurd:
> >
> > --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
> > +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
> > @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
> > -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
> > -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
> >
> > The changes look okay to me.  A second review is probably warranted at
> > this stage.
>
> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
> and requires manual edit to get it right.
Adhemerval Zanella Jan. 29, 2022, 7:59 p.m. UTC | #9
On 29/01/2022 01:55, H.J. Lu wrote:
> On Thu, Jan 27, 2022 at 9:05 AM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>>
>>
>> On 27/01/2022 13:11, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
>>>> controlling terminal), so it would make more sense to actually fit
>>>> it on the file actions API.
>>>>
>>>> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
>>>> implicit by the presence of tcsetpgrp file action.
>>>>
>>>> The posix/tst-spawn6.c is also fixed when TTY can is not present.
> 
> I still got
> 
> [hjl@gnu-tgl-2 build-x86_64-linux]$ cat posix/tst-spawn6.out
> error: xopen.c:28: open64 ("/dev/tty", 0x0, 0600): No such device or address
> error: 1 test failures
> [hjl@gnu-tgl-2 build-x86_64-linux]$
> 
> It happened when I did
> 
> $ nohup make check&
> $ logout

That's because I am using the wrong errno value to check if the tty is
present (ENOENT).  I have changed to ENXIO.

> 
>>>> Checked on x86_64-linux-gnu and i686-linux-gnu.
>>>
>>> This has an ABI check failure on Hurd:
>>>
>>> --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
>>> +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
>>> @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
>>> -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
>>> -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
>>>
>>> The changes look okay to me.  A second review is probably warranted at
>>> this stage.
>>
>> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
>> and requires manual edit to get it right.
> 
> 
>
Florian Weimer March 1, 2022, 12:42 p.m. UTC | #10
* Samuel Thibault:

> Adhemerval Zanella, le jeu. 27 janv. 2022 15:09:29 -0300, a ecrit:
>> On 27/01/2022 14:15, Samuel Thibault wrote:
>> > Adhemerval Zanella via Libc-alpha, le jeu. 27 janv. 2022 14:04:28 -0300, a ecrit:
>> >> On 27/01/2022 13:11, Florian Weimer wrote:
>> >>> * Adhemerval Zanella:
>> >>>
>> >>>> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
>> >>>> controlling terminal), so it would make more sense to actually fit
>> >>>> it on the file actions API.
>> >>>>
>> >>>> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
>> >>>> implicit by the presence of tcsetpgrp file action.
>> >>>>
>> >>>> The posix/tst-spawn6.c is also fixed when TTY can is not present.
>> >>>>
>> >>>> Checked on x86_64-linux-gnu and i686-linux-gnu.
>> >>>
>> >>> This has an ABI check failure on Hurd:
>> >>>
>> >>> --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
>> >>> +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
>> >>> @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
>> >>> -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
>> >>> -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
>> >>>
>> >>> The changes look okay to me.  A second review is probably warranted at
>> >>> this stage.
>> >>
>> >> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
>> >> and requires manual edit to get it right.
>> > 
>> > I don't think I understand.  How is it different in the linux case?
>> 
>> A 'make update-abi' with a default 'configure --prefix=/usr' creates two
>> files on source:
>
>>         modified:   sysdeps/mach/hurd/libhurduser.abilist
>>         modified:   sysdeps/mach/libmachuser.abilist
>
> Ok, would the attached patch be ok? We do not track ABI on these libs.

Why is there no tracking?  Should they use GLIBC_PRIVATE symbols only
then?

Thanks,
Florian
Samuel Thibault March 6, 2022, 7:28 p.m. UTC | #11
Florian Weimer, le mar. 01 mars 2022 13:42:03 +0100, a ecrit:
> * Samuel Thibault:
> 
> > Adhemerval Zanella, le jeu. 27 janv. 2022 15:09:29 -0300, a ecrit:
> >> On 27/01/2022 14:15, Samuel Thibault wrote:
> >> > Adhemerval Zanella via Libc-alpha, le jeu. 27 janv. 2022 14:04:28 -0300, a ecrit:
> >> >> On 27/01/2022 13:11, Florian Weimer wrote:
> >> >>> * Adhemerval Zanella:
> >> >>>
> >> >>>> The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
> >> >>>> controlling terminal), so it would make more sense to actually fit
> >> >>>> it on the file actions API.
> >> >>>>
> >> >>>> Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
> >> >>>> implicit by the presence of tcsetpgrp file action.
> >> >>>>
> >> >>>> The posix/tst-spawn6.c is also fixed when TTY can is not present.
> >> >>>>
> >> >>>> Checked on x86_64-linux-gnu and i686-linux-gnu.
> >> >>>
> >> >>> This has an ABI check failure on Hurd:
> >> >>>
> >> >>> --- ../sysdeps/mach/hurd/i386/libc.abilist      2022-01-27 10:04:20.120812828 -0500
> >> >>> +++ /home/bmg/build/glibcs/i686-gnu/glibc/libc.symlist  2022-01-27 10:43:39.646804376 -0500
> >> >>> @@ -2292,2 +2291,0 @@ GLIBC_2.35 posix_spawn_file_actions_addt
> >> >>> -GLIBC_2.35 posix_spawnattr_tcgetpgrp_np F
> >> >>> -GLIBC_2.35 posix_spawnattr_tcsetpgrp_np F
> >> >>>
> >> >>> The changes look okay to me.  A second review is probably warranted at
> >> >>> this stage.
> >> >>
> >> >> Thanks.  It is really annoying that hurd make update-abi adds a bunch of files
> >> >> and requires manual edit to get it right.
> >> > 
> >> > I don't think I understand.  How is it different in the linux case?
> >> 
> >> A 'make update-abi' with a default 'configure --prefix=/usr' creates two
> >> files on source:
> >
> >>         modified:   sysdeps/mach/hurd/libhurduser.abilist
> >>         modified:   sysdeps/mach/libmachuser.abilist
> >
> > Ok, would the attached patch be ok? We do not track ABI on these libs.
> 
> Why is there no tracking?

Because the libmachuser and libhurduser content is generated from the
.defs files provided by the gnumach and hurd sources (you can think of
this as a list of system calls), so they are moving at their own pace,
and the precise list will depend on the precise hurd upstream version
that one is using, not on the glibc source. Yes, this is suboptimal for
symbol tracking, but more flexible for development than hardlisting
everything.

https://sourceware.org/bugzilla/show_bug.cgi?id=23286

Samuel
diff mbox series

Patch

diff --git a/NEWS b/NEWS
index a9f25d3225..88ab93b4f4 100644
--- a/NEWS
+++ b/NEWS
@@ -129,10 +129,9 @@  Major new features:
 * On Linux, the epoll_pwait2 function has been added.  It is similar to
   epoll_wait with the difference the timeout has nanoseconds resolution.
 
-* 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 race free manner.  These
-  functions are GNU extensions.
+* The function posix_spawn_file_actions_addtcsetpgrp_np has been added,
+  enabling posix_spawn and posix_spawnp to set the controlling terminal in
+  the new process in a race free manner.  This function is a GNU extension.
 
 Deprecated and removed features, and other changes affecting compatibility:
 
diff --git a/posix/Makefile b/posix/Makefile
index 2b5b791374..9b30b53a7c 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -58,13 +58,13 @@  routines :=								      \
 	spawn_faction_addopen spawn_faction_adddup2 spawn_valid_fd	      \
 	spawn_faction_addchdir spawn_faction_addfchdir			      \
 	spawn_faction_addclosefrom					      \
+	spawn_faction_addtcsetpgrp_np					      \
 	spawnattr_init spawnattr_destroy				      \
 	spawnattr_getdefault spawnattr_setdefault			      \
 	spawnattr_getflags spawnattr_setflags				      \
 	spawnattr_getpgroup spawnattr_setpgroup spawn spawnp spawni	      \
 	spawnattr_getsigmask spawnattr_getschedpolicy spawnattr_getschedparam \
 	spawnattr_setsigmask spawnattr_setschedpolicy spawnattr_setschedparam \
-	spawnattr_tcgetpgrp spawnattr_tcsetpgrp				      \
 	posix_madvise							      \
 	get_child_max sched_cpucount sched_cpualloc sched_cpufree \
 	streams-compat \
diff --git a/posix/Versions b/posix/Versions
index e4f4f649b0..3753810864 100644
--- a/posix/Versions
+++ b/posix/Versions
@@ -157,8 +157,7 @@  libc {
     posix_spawn_file_actions_addclosefrom_np;
   }
   GLIBC_2.35 {
-    posix_spawnattr_tcgetpgrp_np;
-    posix_spawnattr_tcsetpgrp_np;
+    posix_spawn_file_actions_addtcsetpgrp_np;
   }
   GLIBC_PRIVATE {
     __libc_fork; __libc_pread; __libc_pwrite;
diff --git a/posix/spawn.h b/posix/spawn.h
index 7779020250..8ef63e6c97 100644
--- a/posix/spawn.h
+++ b/posix/spawn.h
@@ -34,8 +34,7 @@  typedef struct
   sigset_t __ss;
   struct sched_param __sp;
   int __policy;
-  int __ctty_fd;
-  int __pad[15];
+  int __pad[16];
 } posix_spawnattr_t;
 
 
@@ -60,7 +59,6 @@  typedef struct
 #ifdef __USE_GNU
 # define POSIX_SPAWN_USEVFORK		0x40
 # define POSIX_SPAWN_SETSID		0x80
-# define POSIX_SPAWN_TCSETPGROUP	0x100
 #endif
 
 
@@ -168,19 +166,6 @@  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));
-
-/* 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));
-#endif
-
 /* Initialize data structure for file attribute for `spawn' call.  */
 extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *
 					  __file_actions)
@@ -235,6 +220,13 @@  posix_spawn_file_actions_addclosefrom_np (posix_spawn_file_actions_t *,
 					  int __from)
      __THROW __nonnull ((1));
 
+/* Add an action fo set the terminal foregroup process group on the terminal
+   associated with TCFD.  */
+extern int
+posix_spawn_file_actions_addtcsetpgrp_np (posix_spawn_file_actions_t *,
+					  int __tcfd)
+     __THROW __nonnull ((1));
+
 #endif
 
 __END_DECLS
diff --git a/posix/spawn_faction_addtcsetpgrp_np.c b/posix/spawn_faction_addtcsetpgrp_np.c
new file mode 100644
index 0000000000..51e66ee22f
--- /dev/null
+++ b/posix/spawn_faction_addtcsetpgrp_np.c
@@ -0,0 +1,50 @@ 
+/* Add a closefrom to a file action list for posix_spawn.
+   Copyright (C) 2022 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 <spawn.h>
+#include <unistd.h>
+#include <spawn_int.h>
+
+int
+__posix_spawn_file_actions_addtcsetpgrp_np (posix_spawn_file_actions_t
+					    *file_actions, int tcfd)
+{
+  struct __spawn_action *rec;
+
+  if (!__spawn_valid_fd (tcfd))
+    return EBADF;
+
+  /* Allocate more memory if needed.  */
+  if (file_actions->__used == file_actions->__allocated
+      && __posix_spawn_file_actions_realloc (file_actions) != 0)
+    /* This can only mean we ran out of memory.  */
+    return ENOMEM;
+
+  /* Add the new value.  */
+  rec = &file_actions->__actions[file_actions->__used];
+  rec->tag = spawn_do_tcsetpgrp;
+  rec->action.setpgrp_action.fd = tcfd;
+
+  /* Account for the new entry.  */
+  ++file_actions->__used;
+
+  return 0;
+}
+weak_alias (__posix_spawn_file_actions_addtcsetpgrp_np,
+	    posix_spawn_file_actions_addtcsetpgrp_np)
diff --git a/posix/spawn_faction_destroy.c b/posix/spawn_faction_destroy.c
index eb5b727d34..add8799bb8 100644
--- a/posix/spawn_faction_destroy.c
+++ b/posix/spawn_faction_destroy.c
@@ -40,6 +40,7 @@  __posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *file_actions)
 	case spawn_do_dup2:
 	case spawn_do_fchdir:
 	case spawn_do_closefrom:
+	case spawn_do_tcsetpgrp:
 	  /* No cleanup required.  */
 	  break;
 	}
diff --git a/posix/spawn_int.h b/posix/spawn_int.h
index f683db6217..f134d15b06 100644
--- a/posix/spawn_int.h
+++ b/posix/spawn_int.h
@@ -34,6 +34,7 @@  struct __spawn_action
     spawn_do_chdir,
     spawn_do_fchdir,
     spawn_do_closefrom,
+    spawn_do_tcsetpgrp
   } tag;
 
   union
@@ -66,6 +67,10 @@  struct __spawn_action
     {
       int from;
     } closefrom_action;
+    struct
+    {
+      int fd;
+    } setpgrp_action;
   } action;
 };
 
diff --git a/posix/spawnattr_setflags.c b/posix/spawnattr_setflags.c
index 603bfcf911..3e6fe4ef03 100644
--- a/posix/spawnattr_setflags.c
+++ b/posix/spawnattr_setflags.c
@@ -26,8 +26,7 @@ 
 		   | POSIX_SPAWN_SETSCHEDPARAM				      \
 		   | POSIX_SPAWN_SETSCHEDULER				      \
 		   | POSIX_SPAWN_SETSID					      \
-		   | POSIX_SPAWN_USEVFORK				      \
-		   | POSIX_SPAWN_TCSETPGROUP)
+		   | POSIX_SPAWN_USEVFORK)
 
 /* Store flags in the attribute structure.  */
 int
diff --git a/posix/spawnattr_tcgetpgrp.c b/posix/spawnattr_tcgetpgrp.c
deleted file mode 100644
index 8db33e4474..0000000000
--- a/posix/spawnattr_tcgetpgrp.c
+++ /dev/null
@@ -1,26 +0,0 @@ 
-/* Get the controlling terminal option.
-   Copyright (C) 2022 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_tcgetpgrp_np (const posix_spawnattr_t *attr, int *fd)
-{
-  *fd = attr->__ctty_fd;
-  return 0;
-}
diff --git a/posix/spawnattr_tcsetpgrp.c b/posix/spawnattr_tcsetpgrp.c
deleted file mode 100644
index c3b2ea2718..0000000000
--- a/posix/spawnattr_tcsetpgrp.c
+++ /dev/null
@@ -1,26 +0,0 @@ 
-/* Set the controlling terminal option.
-   Copyright (C) 2022 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;
-}
diff --git a/posix/tst-spawn6.c b/posix/tst-spawn6.c
index 5f95bd1938..63ebd3f2a3 100644
--- a/posix/tst-spawn6.c
+++ b/posix/tst-spawn6.c
@@ -29,12 +29,11 @@ 
 #include <support/check.h>
 #include <support/xunistd.h>
 #include <sys/wait.h>
+#include <stdlib.h>
 
 static int
-handle_restart (const char *argv1)
+handle_restart (const char *argv1, const char *argv2)
 {
-  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.  */
@@ -50,9 +49,20 @@  handle_restart (const char *argv1)
       TEST_VERIFY (pgid != pgrp);
     }
 
-  TEST_COMPARE (tcgetpgrp (fd), pgrp);
+  char *endptr;
+  long int tcfd = strtol (argv2, &endptr, 10);
+  if (*endptr != '\0' || tcfd > INT_MAX)
+    FAIL_EXIT1 ("invalid file descriptor name: %s", argv2);
+  if (tcfd != -1)
+    {
+      TEST_COMPARE (fcntl (tcfd, F_GETFD), -1);
+      TEST_COMPARE (errno, EBADF);
+    }
 
+  int fd = xopen (_PATH_TTY, O_RDONLY, 0600);
+  TEST_COMPARE (tcgetpgrp (fd), pgrp);
   xclose (fd);
+
   return 0;
 }
 
@@ -62,6 +72,7 @@  static int restart;
 
 static void
 run_subprogram (int argc, char *argv[], const posix_spawnattr_t *attr,
+		const posix_spawn_file_actions_t *actions, int tcfd,
 		int exp_err)
 {
   short int flags;
@@ -69,7 +80,9 @@  run_subprogram (int argc, char *argv[], const posix_spawnattr_t *attr,
   bool setpgrp = flags & POSIX_SPAWN_SETPGROUP;
 
   char *spargv[9];
+  TEST_VERIFY_EXIT (((argc - 1) + 4) < array_length (spargv));
   char pgrp[INT_STRLEN_BOUND (pid_t)];
+  char tcfdstr[INT_STRLEN_BOUND (int)];
 
   int i = 0;
   for (; i < argc - 1; i++)
@@ -83,11 +96,12 @@  run_subprogram (int argc, char *argv[], const posix_spawnattr_t *attr,
       snprintf (pgrp, sizeof pgrp, "%d", getpgrp ());
       spargv[i++] = pgrp;
     }
+  snprintf (tcfdstr, sizeof tcfdstr, "%d", tcfd);
+  spargv[i++] = tcfdstr;
   spargv[i] = NULL;
-  TEST_VERIFY_EXIT (i < array_length (spargv));
 
   pid_t pid;
-  TEST_COMPARE (posix_spawn (&pid, argv[1], NULL, attr, spargv, environ),
+  TEST_COMPARE (posix_spawn (&pid, argv[1], actions, attr, spargv, environ),
 		exp_err);
   if (exp_err != 0)
     return;
@@ -114,44 +128,55 @@  do_test (int argc, char *argv[])
    */
 
   if (restart)
-    return handle_restart (argv[1]);
+    return handle_restart (argv[1], argv[2]);
 
-  int tcfd = xopen (_PATH_TTY, O_RDONLY, 0600);
+  int tcfd = open64 (_PATH_TTY, O_RDONLY, 0600);
+  if (tcfd == -1)
+    {
+      if (errno == ENOENT)
+	FAIL_UNSUPPORTED ("terminal not available, skipping test");
+      FAIL_EXIT1 ("open64 (\"%s\", 0x%x, 0600): %m", _PATH_TTY, O_RDONLY);
+    }
 
-  /* Check getters and setters.  */
+  /* Check setting the controlling terminal without changing the group.  */
   {
     posix_spawnattr_t attr;
     TEST_COMPARE (posix_spawnattr_init (&attr), 0);
-    TEST_COMPARE (posix_spawnattr_tcsetpgrp_np (&attr, tcfd), 0);
+    posix_spawn_file_actions_t actions;
+    TEST_COMPARE (posix_spawn_file_actions_init (&actions), 0);
+    TEST_COMPARE (posix_spawn_file_actions_addtcsetpgrp_np (&actions, tcfd),
+		  0);
 
-    int fd;
-    TEST_COMPARE (posix_spawnattr_tcgetpgrp_np (&attr, &fd), 0);
-    TEST_COMPARE (tcfd, fd);
+    run_subprogram (argc, argv, &attr, &actions, -1, 0);
   }
 
-  /* Check setting the controlling terminal without changing the group.  */
+  /* 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),
+    TEST_COMPARE (posix_spawnattr_setflags (&attr, POSIX_SPAWN_SETPGROUP), 0);
+    posix_spawn_file_actions_t actions;
+    TEST_COMPARE (posix_spawn_file_actions_init (&actions), 0);
+    TEST_COMPARE (posix_spawn_file_actions_addtcsetpgrp_np (&actions, tcfd),
 		  0);
-    TEST_COMPARE (posix_spawnattr_tcsetpgrp_np (&attr, tcfd), 0);
 
-    run_subprogram (argc, argv, &attr, 0);
+    run_subprogram (argc, argv, &attr, &actions, -1, 0);
   }
 
-  /* Check setting both the controlling terminal and the create a new process
-     group.  */
+  /* Same as before, but check if the addclose file actions closes the terminal
+     file descriptor.  */
   {
     posix_spawnattr_t attr;
     TEST_COMPARE (posix_spawnattr_init (&attr), 0);
-    TEST_COMPARE (posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP
-						   | POSIX_SPAWN_SETPGROUP),
+    TEST_COMPARE (posix_spawnattr_setflags (&attr, POSIX_SPAWN_SETPGROUP), 0);
+    posix_spawn_file_actions_t actions;
+    TEST_COMPARE (posix_spawn_file_actions_init (&actions), 0);
+    TEST_COMPARE (posix_spawn_file_actions_addtcsetpgrp_np (&actions, tcfd),
 		  0);
-    TEST_COMPARE (posix_spawnattr_setpgroup (&attr, 0), 0);
-    TEST_COMPARE (posix_spawnattr_tcsetpgrp_np (&attr, tcfd), 0);
+    TEST_COMPARE (posix_spawn_file_actions_addclose (&actions, tcfd), 0);
 
-    run_subprogram (argc, argv, &attr, 0);
+    run_subprogram (argc, argv, &attr, &actions, tcfd, 0);
   }
 
   /* Trying to set the controlling terminal after a setsid incurs in a ENOTTY
@@ -159,11 +184,13 @@  do_test (int argc, char *argv[])
   {
     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);
+    TEST_COMPARE (posix_spawnattr_setflags (&attr, POSIX_SPAWN_SETSID), 0);
+    posix_spawn_file_actions_t actions;
+    TEST_COMPARE (posix_spawn_file_actions_init (&actions), 0);
+    TEST_COMPARE (posix_spawn_file_actions_addtcsetpgrp_np (&actions, tcfd),
+		  0);
 
-    run_subprogram (argc, argv, &attr, ENOTTY);
+    run_subprogram (argc, argv, &attr, &actions, -1, ENOTTY);
   }
 
   xclose (tcfd);
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index ecf8c0992e..4dc87e9061 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2288,6 +2288,7 @@  GLIBC_2.34 timespec_getres F
 GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 close_range F
+GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_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/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c
index bccdd013bf..f19b688411 100644
--- a/sysdeps/mach/hurd/spawni.c
+++ b/sysdeps/mach/hurd/spawni.c
@@ -390,19 +390,6 @@  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)
     {
@@ -643,6 +630,19 @@  retry:
 	  case spawn_do_closefrom:
 	    err = do_closefrom (action->action.closefrom_action.from);
 	    break;
+
+	  case spawn_do_tcsetpgrp:
+	    {
+	      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 (action->action.setpgrp_action.fd, pgrp);
+	    }
 	  }
 
 	if (err)
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 9dd574d9e2..1b63d9e447 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2615,5 +2615,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_np F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index f66704877e..e7e4cf7d2a 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2712,8 +2712,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 97aa3da1ad..bc3d228e31 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -2376,5 +2376,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_np F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 18f4364856..db7039c4ab 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -495,8 +495,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 2c12c020b1..d2add4fb49 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -492,8 +492,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 7f28516feb..355d72a30c 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2651,5 +2651,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_np F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 9776f20763..3df39bb28c 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2600,8 +2600,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 96b50d0a9b..c4da358f80 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2784,8 +2784,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 9b2eebfbf1..241bac70ea 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2550,8 +2550,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 71cd35488e..78bf372b72 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -496,8 +496,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 ced01a501d..00df5c901f 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2727,8 +2727,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 5406c01f1d..e8118569c3 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2700,5 +2700,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_np F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index 53b8ade4c3..c0d2373e64 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2697,5 +2697,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 919973ea46..2d0fd04f54 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2692,8 +2692,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 cf5a8dc120..e39ccfb312 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2690,8 +2690,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 003c3bd0a6..1e900f86e4 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2698,8 +2698,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 73629c2f21..9145ba7931 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2601,8 +2601,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 9e8645ebc0..e95d60d926 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2739,5 +2739,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_np F
diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist
index 7ed49ee71e..ca934e374b 100644
--- a/sysdeps/unix/sysv/linux/or1k/libc.abilist
+++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist
@@ -1379,6 +1379,7 @@  GLIBC_2.35 posix_spawn_file_actions_addclosefrom_np F
 GLIBC_2.35 posix_spawn_file_actions_adddup2 F
 GLIBC_2.35 posix_spawn_file_actions_addfchdir_np F
 GLIBC_2.35 posix_spawn_file_actions_addopen F
+GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
 GLIBC_2.35 posix_spawn_file_actions_destroy F
 GLIBC_2.35 posix_spawn_file_actions_init F
 GLIBC_2.35 posix_spawnattr_destroy F
@@ -1395,8 +1396,6 @@  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 3d1ba9887c..3820b9f235 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2754,8 +2754,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 d979a3b93b..464dc27fcd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2787,8 +2787,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 44688e52cf..2f7e58747f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2509,8 +2509,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 40682711eb..4f3043d913 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2811,5 +2811,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_np F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index e239d626b3..84b6ac815a 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -2378,5 +2378,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_np F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index ab0c4e7092..4d5c19c56a 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2578,5 +2578,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 74e3a4651f..7c5ee8d569 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2752,8 +2752,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 e5553f06b2..50de0b46cf 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2546,8 +2546,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 9662041cd4..66fba013ca 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2607,8 +2607,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 bf90e924a6..38703f8aa0 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2604,8 +2604,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 ddb0d0621f..6df55eb765 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2747,8 +2747,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 ca14224cb7..b90569d881 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2573,8 +2573,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 93359c708b..d703485e3f 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -164,17 +164,6 @@  __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
@@ -279,6 +268,16 @@  __spawni_child (void *arguments)
 		if (r != 0 && !__closefrom_fallback (lowfd, false))
 		  goto fail;
 	      } break;
+
+	    case spawn_do_tcsetpgrp:
+	      {
+		/* 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 (action->action.setpgrp_action.fd, pgrp) != 0)
+		  goto fail;
+	      }
 	    }
 	}
     }
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 661d928adf..e88b0f101f 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2524,8 +2524,7 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_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 bb8058dfa4..e0755272eb 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2630,5 +2630,4 @@  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.35 posix_spawn_file_actions_addtcsetpgrp_np F