glibc/sysdeps
Adhemerval Zanella e83be73091 posix: Fix open file action for posix_spawn on Linux
On posix_spawn open file action (issued by posix_spawn_file_actions_addopen)
POSIX states that if fildes was already an open file descriptor, it shall be
closed before the new file is openedi [1].  This avoid pontential issues when
posix_spawn plus addopen action is called with the process already at maximum
number of file descriptor opened and also for multiple actions on single-open
special paths (like /dev/watchdog).

This fixes its behavior on Linux posix_spawn implementation and also adds
a tests to check for its behavior.

Checked on x86_64.

	* posix/Makefile (tests): Add tst-spawn3.
	* posix/tst-spawn3.c: New file.
	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Close file descriptor
	if it is already opened for open action.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addclose.html
2016-09-28 14:07:35 -07:00
..
aarch64 Add femode_t functions: aarch64. 2016-09-07 16:41:20 +00:00
alpha Add femode_t functions: alpha. 2016-09-07 16:42:19 +00:00
arm Installed header hygiene (BZ#20366): Test of installed headers. 2016-09-23 08:43:56 -04:00
generic Installed-header hygiene (BZ#20366): stack_t. 2016-09-23 08:43:56 -04:00
gnu Installed-header hygiene (BZ#20366): obsolete BSD u_* types. 2016-09-23 08:43:56 -04:00
hppa Add femode_t functions: hppa. 2016-09-07 16:43:43 +00:00
i386 Installed-header hygiene (BZ#20366): stack_t. 2016-09-23 08:43:56 -04:00
ia64 Remove the ptw-% patterns 2016-09-14 16:02:06 +02:00
ieee754 Build s_nan* objects from a generic template 2016-09-20 14:37:42 -05:00
init_array Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
m68k Installed-header hygiene (BZ#20366): stack_t. 2016-09-23 08:43:56 -04:00
mach Installed-header hygiene (BZ#20366): stack_t. 2016-09-23 08:43:56 -04:00
microblaze Add femode_t functions. 2016-09-07 16:40:09 +00:00
mips Installed header hygiene (BZ#20366): Test of installed headers. 2016-09-23 08:43:56 -04:00
nacl Remove the ptw-% patterns 2016-09-14 16:02:06 +02:00
nios2 Add femode_t functions. 2016-09-07 16:40:09 +00:00
nptl Installed-header hygiene (BZ#20366): time.h types. 2016-09-23 08:43:56 -04:00
posix hurd: fix fcntl visibility 2016-09-18 23:48:55 +02:00
powerpc powerpc: Fix POWER9 implies 2016-09-19 09:35:38 -03:00
pthread Installed-header hygiene (BZ#20366): time.h types. 2016-09-23 08:43:56 -04:00
s390 Remove the ptw-% patterns 2016-09-14 16:02:06 +02:00
sh Add femode_t functions: sh. 2016-09-07 16:48:08 +00:00
sparc Remove remnants of .og patterns 2016-09-20 12:18:13 +02:00
tile Add femode_t functions. 2016-09-07 16:40:09 +00:00
unix posix: Fix open file action for posix_spawn on Linux 2016-09-28 14:07:35 -07:00
wordsize-32 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
wordsize-64 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
x86 Installed header hygiene (BZ#20366): Test of installed headers. 2016-09-23 08:43:56 -04:00
x86_64 Add femode_t functions. 2016-09-07 16:40:09 +00:00