[glibc] posix: Add terminal control setting support for posix_spawn
Florian Weimer
fweimer@redhat.com
Thu Jan 27 11:57:49 GMT 2022
* Adhemerval Zanella:
> I did not considered the closefrom in conjunction with closefrom file
> action and making a file action does make sense indeed. Maybe a better
> approach would be to remove posix_spawnattr_tcsetpgrp_np and
> posix_spawnattr_tcsetpgrp_np and add:
>
> int posix_spawn_file_actions_tcsetgrp_np (posix_spawn_file_actions_t *,
> int fd);
>
> Similar to posix_spawn_file_actions_addfchdir_np.
>
> So to create a process and set the controlling terminal, one can use the
> following sequence:
>
> int tcfd = open (_PATH_TTY, O_RDONLY, 0600);
>
> posix_spawnattr_t attr;
> posix_spawnattr_init (&attr);
> posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP);
Why is POSIX_SPAWN_TCSETPGROUP needed?
> posix_spawn_file_actions_t actions;
> posix_spawn_file_actions_init (&actions);
> posix_spawn_file_actions_tcsetgrp_np (&actions, tcfd);
>
> So users would be able to add a posix_spawn_file_actions_addclose or
> posix_spawn_file_actions_addclosefrom_np.
This would address my concern, yes.
Thanks,
Florian
More information about the Libc-alpha
mailing list