mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-24 17:51:17 +03:00
posix: Replace posix_spawnattr_tc{get,set}pgrp_np with posix_spawn_file_actions_addtcsetpgrp_np
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. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user