mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
342cc934a3
Currently there is no proper way to set the controlling terminal through posix_spawn in race free manner [1]. This forces shell implementations to keep using fork+exec when launching background process groups, even when using posix_spawn yields better performance. This patch adds a new GNU extension so the creating process can configure the created process terminal group. This is done with a new flag, POSIX_SPAWN_TCSETPGROUP, along with two new attribute functions: posix_spawnattr_tcsetpgrp_np, and posix_spawnattr_tcgetpgrp_np. The function sets a new attribute, spawn-tcgroupfd, that references to the controlling terminal. The controlling terminal is set after the spawn-pgroup attribute, and uses the spawn-tcgroupfd along with current creating process group (so it is composable with POSIX_SPAWN_SETPGROUP). To create a process and set the controlling terminal, one can use the following sequence: posix_spawnattr_t attr; posix_spawnattr_init (&attr); posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP); posix_spawnattr_tcsetpgrp_np (&attr, tcfd); If the idea is also to create a new process groups: posix_spawnattr_t attr; posix_spawnattr_init (&attr); posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP | POSIX_SPAWN_SETPGROUP); posix_spawnattr_tcsetpgrp_np (&attr, tcfd); posix_spawnattr_setpgroup (&attr, 0); The controlling terminal file descriptor is ignored if the new flag is not set. This interface is slight different than the one provided by QNX [2], which only provides the POSIX_SPAWN_TCSETPGROUP flag. The QNX documentation does not specify how the controlling terminal is obtained nor how it iteracts with POSIX_SPAWN_SETPGROUP. Since a glibc implementation is library based, it is more straightforward and avoid requires additional file descriptor operations to request the caller to setup the controlling terminal file descriptor (and it also allows a bit less error handling by posix_spawn). Checked on x86_64-linux-gnu and i686-linux-gnu. [1] https://github.com/ksh93/ksh/issues/79 [2] https://www.qnx.com/developers/docs/7.0.0/index.html#com.qnx.doc.neutrino.lib_ref/topic/p/posix_spawn.html Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com> |
||
---|---|---|
.. | ||
arpa | ||
bits | ||
gnu | ||
net | ||
netinet | ||
programs | ||
protocols | ||
rpc | ||
rpcsvc | ||
sys | ||
aio.h | ||
aliases.h | ||
alloc_buffer.h | ||
alloca.h | ||
allocate_once.h | ||
ar.h | ||
argp-fmtstream.h | ||
argp.h | ||
argz.h | ||
array_length.h | ||
assert.h | ||
atomic_wide_counter.h | ||
atomic.h | ||
byteswap.h | ||
clone_internal.h | ||
complex.h | ||
cpio.h | ||
crypt.h | ||
ctype.h | ||
des.h | ||
dirent.h | ||
dlfcn.h | ||
dso_handle.h | ||
elf.h | ||
endian.h | ||
envz.h | ||
err.h | ||
errno.h | ||
error.h | ||
execinfo.h | ||
fcntl.h | ||
features-time64.h | ||
features.h | ||
fenv.h | ||
file_change_detection.h | ||
filename.h | ||
float.h | ||
fmtmsg.h | ||
fnmatch.h | ||
fpu_control.h | ||
fstab.h | ||
fts.h | ||
ftw.h | ||
gconv.h | ||
getopt_int.h | ||
getopt.h | ||
glob.h | ||
gmp.h | ||
gnu-versions.h | ||
grp-merge.h | ||
grp.h | ||
gshadow.h | ||
iconv.h | ||
idx.h | ||
ifaddrs.h | ||
ifreq.h | ||
ifunc-impl-list.h | ||
inline-hashtab.h | ||
intprops.h | ||
inttypes.h | ||
langinfo.h | ||
lastlog.h | ||
libc-diag.h | ||
libc-internal.h | ||
libc-pointer-arith.h | ||
libc-symbols.h | ||
libgen.h | ||
libintl.h | ||
limits.h | ||
link.h | ||
list_t.h | ||
list.h | ||
locale.h | ||
loop_unroll.h | ||
malloc.h | ||
math-narrow-eval.h | ||
math.h | ||
mcheck.h | ||
memory.h | ||
mntent.h | ||
monetary.h | ||
mqueue.h | ||
netdb.h | ||
netgroup.h | ||
nl_types.h | ||
nss_dns.h | ||
nss_files.h | ||
nss.h | ||
nsswitch.h | ||
obstack.h | ||
plural-exp.h | ||
poll.h | ||
printf.h | ||
pthread.h | ||
pty.h | ||
pwd.h | ||
random-bits.h | ||
re_comp.h | ||
regex.h | ||
regexp.h | ||
register-atfork.h | ||
resolv.h | ||
rounding-mode.h | ||
rtld-malloc.h | ||
sched.h | ||
scratch_buffer.h | ||
search.h | ||
set-hooks.h | ||
setjmp.h | ||
sgtty.h | ||
shadow.h | ||
shlib-compat.h | ||
shm-directory.h | ||
signal.h | ||
spawn.h | ||
stab.h | ||
stackinfo.h | ||
stap-probe.h | ||
stdc-predef.h | ||
stdint.h | ||
stdio_ext.h | ||
stdio.h | ||
stdlib.h | ||
string.h | ||
strings.h | ||
struct___timeb64.h | ||
struct___timespec64.h | ||
struct___timeval64.h | ||
stubs-prologue.h | ||
syscall.h | ||
sysexits.h | ||
syslog.h | ||
tar.h | ||
termios.h | ||
tgmath.h | ||
time.h | ||
ttyent.h | ||
uchar.h | ||
ucontext.h | ||
ulimit.h | ||
unistd.h | ||
utime.h | ||
utmp.h | ||
values.h | ||
verify.h | ||
wait.h | ||
wchar.h | ||
wctype.h | ||
wordexp.h |