aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2020-12-25 11:33:02 +0100
committerPhilipp Stephani2020-12-25 11:54:02 +0100
commit3ba34141da77a24c251ee6530f3f72a366fe556e (patch)
tree66b28a4a122d20ca29548c8894fba2c6fa4645f3
parent42d58264db165d265cba68d6dbebc53a50738355 (diff)
downloademacs-3ba34141da77a24c251ee6530f3f72a366fe556e.tar.gz
emacs-3ba34141da77a24c251ee6530f3f72a366fe556e.zip
Import posix_spawn from Gnulib.
posix_spawn is less error-prone than vfork + exec, and can make use of system-specific optimizations like `clone' on Linux. Import Gnulib replacement so that we can use recent additions like `posix_spawn_file_actions_addchdir'. The only manual change are to admin/merge-gnulib and .gitignore. All other changes are due to rerunning merge-gnulib. * admin/merge-gnulib (GNULIB_MODULES): Add posix_spawn-related modules. * .gitignore: Add new generated files.
-rw-r--r--.gitignore2
-rwxr-xr-xadmin/merge-gnulib9
-rw-r--r--lib/gnulib.mk.in302
-rw-r--r--lib/sched.in.h99
-rw-r--r--lib/spawn.c34
-rw-r--r--lib/spawn.in.h974
-rw-r--r--lib/spawn_faction_addchdir.c70
-rw-r--r--lib/spawn_faction_adddup2.c70
-rw-r--r--lib/spawn_faction_destroy.c61
-rw-r--r--lib/spawn_faction_init.c56
-rw-r--r--lib/spawn_int.h72
-rw-r--r--lib/spawnattr_destroy.c28
-rw-r--r--lib/spawnattr_init.c33
-rw-r--r--lib/spawnattr_setdefault.c33
-rw-r--r--lib/spawnattr_setflags.c45
-rw-r--r--lib/spawnattr_setpgroup.c32
-rw-r--r--lib/spawnattr_setsigmask.c33
-rw-r--r--lib/spawni.c349
-rw-r--r--lib/strchrnul.c142
-rw-r--r--lib/strchrnul.valgrind28
-rw-r--r--m4/gnulib-comp.m4144
-rw-r--r--m4/posix_spawn.m4678
-rw-r--r--m4/posix_spawn_faction_addchdir.m420
-rw-r--r--m4/sched_h.m491
-rw-r--r--m4/sh-filename.m422
-rw-r--r--m4/spawn_h.m4136
-rw-r--r--m4/strchrnul.m450
27 files changed, 3612 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index bf7e9349813..f9c0fae4f60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,7 +65,9 @@ lib/ieee754.h
65lib/inttypes.h 65lib/inttypes.h
66lib/libgnu.a 66lib/libgnu.a
67lib/limits.h 67lib/limits.h
68lib/sched.h
68lib/signal.h 69lib/signal.h
70lib/spawn.h
69lib/std*.h 71lib/std*.h
70!lib/std*.in.h 72!lib/std*.in.h
71!lib/stdio-impl.h 73!lib/stdio-impl.h
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 880dc5eef53..f1ed2da69e5 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -39,7 +39,14 @@ GNULIB_MODULES='
39 getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog 39 getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
40 ieee754-h ignore-value intprops largefile libgmp lstat 40 ieee754-h ignore-value intprops largefile libgmp lstat
41 manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime nstrftime 41 manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime nstrftime
42 pathmax pipe2 pselect pthread_sigmask 42 pathmax pipe2
43 posix_spawn posix_spawn_file_actions_addchdir
44 posix_spawn_file_actions_adddup2 posix_spawn_file_actions_destroy
45 posix_spawn_file_actions_init
46 posix_spawnattr_destroy posix_spawnattr_init
47 posix_spawnattr_setflags posix_spawnattr_setpgroup
48 posix_spawnattr_setsigdefault posix_spawnattr_setsigmask
49 pselect pthread_sigmask
43 qcopy-acl readlink readlinkat regex 50 qcopy-acl readlink readlinkat regex
44 sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio 51 sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio
45 stpcpy strnlen strtoimax symlink sys_stat sys_time 52 stpcpy strnlen strtoimax symlink sys_stat sys_time
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index a37f9278a31..209c7eef299 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -130,6 +130,17 @@
130# nstrftime \ 130# nstrftime \
131# pathmax \ 131# pathmax \
132# pipe2 \ 132# pipe2 \
133# posix_spawn \
134# posix_spawn_file_actions_addchdir \
135# posix_spawn_file_actions_adddup2 \
136# posix_spawn_file_actions_destroy \
137# posix_spawn_file_actions_init \
138# posix_spawnattr_destroy \
139# posix_spawnattr_init \
140# posix_spawnattr_setflags \
141# posix_spawnattr_setpgroup \
142# posix_spawnattr_setsigdefault \
143# posix_spawnattr_setsigmask \
133# pselect \ 144# pselect \
134# pthread_sigmask \ 145# pthread_sigmask \
135# qcopy-acl \ 146# qcopy-acl \
@@ -393,6 +404,29 @@ GNULIB_PIPE2 = @GNULIB_PIPE2@
393GNULIB_POPEN = @GNULIB_POPEN@ 404GNULIB_POPEN = @GNULIB_POPEN@
394GNULIB_POSIX_MEMALIGN = @GNULIB_POSIX_MEMALIGN@ 405GNULIB_POSIX_MEMALIGN = @GNULIB_POSIX_MEMALIGN@
395GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@ 406GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@
407GNULIB_POSIX_SPAWN = @GNULIB_POSIX_SPAWN@
408GNULIB_POSIX_SPAWNATTR_DESTROY = @GNULIB_POSIX_SPAWNATTR_DESTROY@
409GNULIB_POSIX_SPAWNATTR_GETFLAGS = @GNULIB_POSIX_SPAWNATTR_GETFLAGS@
410GNULIB_POSIX_SPAWNATTR_GETPGROUP = @GNULIB_POSIX_SPAWNATTR_GETPGROUP@
411GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM = @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@
412GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY = @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@
413GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT = @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@
414GNULIB_POSIX_SPAWNATTR_GETSIGMASK = @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@
415GNULIB_POSIX_SPAWNATTR_INIT = @GNULIB_POSIX_SPAWNATTR_INIT@
416GNULIB_POSIX_SPAWNATTR_SETFLAGS = @GNULIB_POSIX_SPAWNATTR_SETFLAGS@
417GNULIB_POSIX_SPAWNATTR_SETPGROUP = @GNULIB_POSIX_SPAWNATTR_SETPGROUP@
418GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM = @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@
419GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY = @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@
420GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT = @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@
421GNULIB_POSIX_SPAWNATTR_SETSIGMASK = @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@
422GNULIB_POSIX_SPAWNP = @GNULIB_POSIX_SPAWNP@
423GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
424GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
425GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
426GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
427GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
428GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@
429GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@
396GNULIB_PREAD = @GNULIB_PREAD@ 430GNULIB_PREAD = @GNULIB_PREAD@
397GNULIB_PRINTF = @GNULIB_PRINTF@ 431GNULIB_PRINTF = @GNULIB_PRINTF@
398GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ 432GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
@@ -425,6 +459,7 @@ GNULIB_RMDIR = @GNULIB_RMDIR@
425GNULIB_RPMATCH = @GNULIB_RPMATCH@ 459GNULIB_RPMATCH = @GNULIB_RPMATCH@
426GNULIB_SCANDIR = @GNULIB_SCANDIR@ 460GNULIB_SCANDIR = @GNULIB_SCANDIR@
427GNULIB_SCANF = @GNULIB_SCANF@ 461GNULIB_SCANF = @GNULIB_SCANF@
462GNULIB_SCHED_YIELD = @GNULIB_SCHED_YIELD@
428GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@ 463GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@
429GNULIB_SELECT = @GNULIB_SELECT@ 464GNULIB_SELECT = @GNULIB_SELECT@
430GNULIB_SETENV = @GNULIB_SETENV@ 465GNULIB_SETENV = @GNULIB_SETENV@
@@ -634,6 +669,11 @@ HAVE_POPEN = @HAVE_POPEN@
634HAVE_POSIX_MEMALIGN = @HAVE_POSIX_MEMALIGN@ 669HAVE_POSIX_MEMALIGN = @HAVE_POSIX_MEMALIGN@
635HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@ 670HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@
636HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ 671HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@
672HAVE_POSIX_SPAWN = @HAVE_POSIX_SPAWN@
673HAVE_POSIX_SPAWNATTR_T = @HAVE_POSIX_SPAWNATTR_T@
674HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
675HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
676HAVE_POSIX_SPAWN_FILE_ACTIONS_T = @HAVE_POSIX_SPAWN_FILE_ACTIONS_T@
637HAVE_PREAD = @HAVE_PREAD@ 677HAVE_PREAD = @HAVE_PREAD@
638HAVE_PSELECT = @HAVE_PSELECT@ 678HAVE_PSELECT = @HAVE_PSELECT@
639HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@ 679HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@
@@ -655,6 +695,8 @@ HAVE_RENAMEAT = @HAVE_RENAMEAT@
655HAVE_REWINDDIR = @HAVE_REWINDDIR@ 695HAVE_REWINDDIR = @HAVE_REWINDDIR@
656HAVE_RPMATCH = @HAVE_RPMATCH@ 696HAVE_RPMATCH = @HAVE_RPMATCH@
657HAVE_SCANDIR = @HAVE_SCANDIR@ 697HAVE_SCANDIR = @HAVE_SCANDIR@
698HAVE_SCHED_H = @HAVE_SCHED_H@
699HAVE_SCHED_YIELD = @HAVE_SCHED_YIELD@
658HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@ 700HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@
659HAVE_SETENV = @HAVE_SETENV@ 701HAVE_SETENV = @HAVE_SETENV@
660HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@ 702HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@
@@ -669,6 +711,7 @@ HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
669HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@ 711HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
670HAVE_SIGSET_T = @HAVE_SIGSET_T@ 712HAVE_SIGSET_T = @HAVE_SIGSET_T@
671HAVE_SLEEP = @HAVE_SLEEP@ 713HAVE_SLEEP = @HAVE_SLEEP@
714HAVE_SPAWN_H = @HAVE_SPAWN_H@
672HAVE_STDINT_H = @HAVE_STDINT_H@ 715HAVE_STDINT_H = @HAVE_STDINT_H@
673HAVE_STPCPY = @HAVE_STPCPY@ 716HAVE_STPCPY = @HAVE_STPCPY@
674HAVE_STPNCPY = @HAVE_STPNCPY@ 717HAVE_STPNCPY = @HAVE_STPNCPY@
@@ -683,6 +726,7 @@ HAVE_STRTOLD = @HAVE_STRTOLD@
683HAVE_STRTOLL = @HAVE_STRTOLL@ 726HAVE_STRTOLL = @HAVE_STRTOLL@
684HAVE_STRTOULL = @HAVE_STRTOULL@ 727HAVE_STRTOULL = @HAVE_STRTOULL@
685HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ 728HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
729HAVE_STRUCT_SCHED_PARAM = @HAVE_STRUCT_SCHED_PARAM@
686HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ 730HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@
687HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ 731HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@
688HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ 732HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
@@ -782,6 +826,7 @@ LIB_EACCESS = @LIB_EACCESS@
782LIB_EXECINFO = @LIB_EXECINFO@ 826LIB_EXECINFO = @LIB_EXECINFO@
783LIB_GETRANDOM = @LIB_GETRANDOM@ 827LIB_GETRANDOM = @LIB_GETRANDOM@
784LIB_MATH = @LIB_MATH@ 828LIB_MATH = @LIB_MATH@
829LIB_POSIX_SPAWN = @LIB_POSIX_SPAWN@
785LIB_PTHREAD = @LIB_PTHREAD@ 830LIB_PTHREAD = @LIB_PTHREAD@
786LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ 831LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
787LIB_TIMER_TIME = @LIB_TIMER_TIME@ 832LIB_TIMER_TIME = @LIB_TIMER_TIME@
@@ -805,7 +850,9 @@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
805NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ 850NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
806NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ 851NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@
807NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@ 852NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@
853NEXT_AS_FIRST_DIRECTIVE_SCHED_H = @NEXT_AS_FIRST_DIRECTIVE_SCHED_H@
808NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ 854NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@
855NEXT_AS_FIRST_DIRECTIVE_SPAWN_H = @NEXT_AS_FIRST_DIRECTIVE_SPAWN_H@
809NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ 856NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
810NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@ 857NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
811NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@ 858NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
@@ -824,7 +871,9 @@ NEXT_FCNTL_H = @NEXT_FCNTL_H@
824NEXT_GETOPT_H = @NEXT_GETOPT_H@ 871NEXT_GETOPT_H = @NEXT_GETOPT_H@
825NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ 872NEXT_INTTYPES_H = @NEXT_INTTYPES_H@
826NEXT_LIMITS_H = @NEXT_LIMITS_H@ 873NEXT_LIMITS_H = @NEXT_LIMITS_H@
874NEXT_SCHED_H = @NEXT_SCHED_H@
827NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ 875NEXT_SIGNAL_H = @NEXT_SIGNAL_H@
876NEXT_SPAWN_H = @NEXT_SPAWN_H@
828NEXT_STDDEF_H = @NEXT_STDDEF_H@ 877NEXT_STDDEF_H = @NEXT_STDDEF_H@
829NEXT_STDINT_H = @NEXT_STDINT_H@ 878NEXT_STDINT_H = @NEXT_STDINT_H@
830NEXT_STDIO_H = @NEXT_STDIO_H@ 879NEXT_STDIO_H = @NEXT_STDIO_H@
@@ -946,6 +995,12 @@ REPLACE_OPENDIR = @REPLACE_OPENDIR@
946REPLACE_PERROR = @REPLACE_PERROR@ 995REPLACE_PERROR = @REPLACE_PERROR@
947REPLACE_POPEN = @REPLACE_POPEN@ 996REPLACE_POPEN = @REPLACE_POPEN@
948REPLACE_POSIX_MEMALIGN = @REPLACE_POSIX_MEMALIGN@ 997REPLACE_POSIX_MEMALIGN = @REPLACE_POSIX_MEMALIGN@
998REPLACE_POSIX_SPAWN = @REPLACE_POSIX_SPAWN@
999REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
1000REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
1001REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
1002REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
1003REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
949REPLACE_PREAD = @REPLACE_PREAD@ 1004REPLACE_PREAD = @REPLACE_PREAD@
950REPLACE_PRINTF = @REPLACE_PRINTF@ 1005REPLACE_PRINTF = @REPLACE_PRINTF@
951REPLACE_PSELECT = @REPLACE_PSELECT@ 1006REPLACE_PSELECT = @REPLACE_PSELECT@
@@ -967,6 +1022,7 @@ REPLACE_REMOVE = @REPLACE_REMOVE@
967REPLACE_RENAME = @REPLACE_RENAME@ 1022REPLACE_RENAME = @REPLACE_RENAME@
968REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ 1023REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
969REPLACE_RMDIR = @REPLACE_RMDIR@ 1024REPLACE_RMDIR = @REPLACE_RMDIR@
1025REPLACE_SCHED_YIELD = @REPLACE_SCHED_YIELD@
970REPLACE_SELECT = @REPLACE_SELECT@ 1026REPLACE_SELECT = @REPLACE_SELECT@
971REPLACE_SETENV = @REPLACE_SETENV@ 1027REPLACE_SETENV = @REPLACE_SETENV@
972REPLACE_SETSTATE = @REPLACE_SETSTATE@ 1028REPLACE_SETSTATE = @REPLACE_SETSTATE@
@@ -1108,11 +1164,13 @@ gamegroup = @gamegroup@
1108gameuser = @gameuser@ 1164gameuser = @gameuser@
1109gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@ 1165gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@
1110gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@ 1166gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@
1167gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7 = @gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7@
1111gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@ 1168gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@
1112gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@ 1169gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@
1113gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec = @gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec@ 1170gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec = @gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec@
1114gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1 = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1@ 1171gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1 = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1@
1115gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36 = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36@ 1172gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36 = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36@
1173gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70 = @gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70@
1116gl_GNULIB_ENABLED_cloexec = @gl_GNULIB_ENABLED_cloexec@ 1174gl_GNULIB_ENABLED_cloexec = @gl_GNULIB_ENABLED_cloexec@
1117gl_GNULIB_ENABLED_dirfd = @gl_GNULIB_ENABLED_dirfd@ 1175gl_GNULIB_ENABLED_dirfd = @gl_GNULIB_ENABLED_dirfd@
1118gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955 = @gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955@ 1176gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955 = @gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955@
@@ -1124,6 +1182,7 @@ gl_GNULIB_ENABLED_lchmod = @gl_GNULIB_ENABLED_lchmod@
1124gl_GNULIB_ENABLED_open = @gl_GNULIB_ENABLED_open@ 1182gl_GNULIB_ENABLED_open = @gl_GNULIB_ENABLED_open@
1125gl_GNULIB_ENABLED_rawmemchr = @gl_GNULIB_ENABLED_rawmemchr@ 1183gl_GNULIB_ENABLED_rawmemchr = @gl_GNULIB_ENABLED_rawmemchr@
1126gl_GNULIB_ENABLED_scratch_buffer = @gl_GNULIB_ENABLED_scratch_buffer@ 1184gl_GNULIB_ENABLED_scratch_buffer = @gl_GNULIB_ENABLED_scratch_buffer@
1185gl_GNULIB_ENABLED_strchrnul = @gl_GNULIB_ENABLED_strchrnul@
1127gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@ 1186gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@
1128gl_GNULIB_ENABLED_utimens = @gl_GNULIB_ENABLED_utimens@ 1187gl_GNULIB_ENABLED_utimens = @gl_GNULIB_ENABLED_utimens@
1129gl_LIBOBJS = @gl_LIBOBJS@ 1188gl_LIBOBJS = @gl_LIBOBJS@
@@ -2270,6 +2329,140 @@ libgnu_a_SOURCES += pipe2.c
2270endif 2329endif
2271## end gnulib module pipe2 2330## end gnulib module pipe2
2272 2331
2332## begin gnulib module posix_spawn
2333ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn))
2334
2335
2336EXTRA_DIST += spawn.c
2337
2338EXTRA_libgnu_a_SOURCES += spawn.c
2339
2340endif
2341## end gnulib module posix_spawn
2342
2343## begin gnulib module posix_spawn-internal
2344ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn-internal))
2345
2346ifneq (,$(gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7))
2347
2348endif
2349EXTRA_DIST += spawn_int.h spawni.c
2350
2351EXTRA_libgnu_a_SOURCES += spawni.c
2352
2353endif
2354## end gnulib module posix_spawn-internal
2355
2356## begin gnulib module posix_spawn_file_actions_addchdir
2357ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_addchdir))
2358
2359
2360EXTRA_DIST += spawn_faction_addchdir.c spawn_int.h
2361
2362EXTRA_libgnu_a_SOURCES += spawn_faction_addchdir.c
2363
2364endif
2365## end gnulib module posix_spawn_file_actions_addchdir
2366
2367## begin gnulib module posix_spawn_file_actions_adddup2
2368ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_adddup2))
2369
2370
2371EXTRA_DIST += spawn_faction_adddup2.c spawn_int.h
2372
2373EXTRA_libgnu_a_SOURCES += spawn_faction_adddup2.c
2374
2375endif
2376## end gnulib module posix_spawn_file_actions_adddup2
2377
2378## begin gnulib module posix_spawn_file_actions_destroy
2379ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_destroy))
2380
2381
2382EXTRA_DIST += spawn_faction_destroy.c
2383
2384EXTRA_libgnu_a_SOURCES += spawn_faction_destroy.c
2385
2386endif
2387## end gnulib module posix_spawn_file_actions_destroy
2388
2389## begin gnulib module posix_spawn_file_actions_init
2390ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_init))
2391
2392
2393EXTRA_DIST += spawn_faction_init.c spawn_int.h
2394
2395EXTRA_libgnu_a_SOURCES += spawn_faction_init.c
2396
2397endif
2398## end gnulib module posix_spawn_file_actions_init
2399
2400## begin gnulib module posix_spawnattr_destroy
2401ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_destroy))
2402
2403
2404EXTRA_DIST += spawnattr_destroy.c
2405
2406EXTRA_libgnu_a_SOURCES += spawnattr_destroy.c
2407
2408endif
2409## end gnulib module posix_spawnattr_destroy
2410
2411## begin gnulib module posix_spawnattr_init
2412ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_init))
2413
2414
2415EXTRA_DIST += spawnattr_init.c
2416
2417EXTRA_libgnu_a_SOURCES += spawnattr_init.c
2418
2419endif
2420## end gnulib module posix_spawnattr_init
2421
2422## begin gnulib module posix_spawnattr_setflags
2423ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setflags))
2424
2425
2426EXTRA_DIST += spawnattr_setflags.c
2427
2428EXTRA_libgnu_a_SOURCES += spawnattr_setflags.c
2429
2430endif
2431## end gnulib module posix_spawnattr_setflags
2432
2433## begin gnulib module posix_spawnattr_setpgroup
2434ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setpgroup))
2435
2436
2437EXTRA_DIST += spawnattr_setpgroup.c
2438
2439EXTRA_libgnu_a_SOURCES += spawnattr_setpgroup.c
2440
2441endif
2442## end gnulib module posix_spawnattr_setpgroup
2443
2444## begin gnulib module posix_spawnattr_setsigdefault
2445ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setsigdefault))
2446
2447
2448EXTRA_DIST += spawnattr_setdefault.c
2449
2450EXTRA_libgnu_a_SOURCES += spawnattr_setdefault.c
2451
2452endif
2453## end gnulib module posix_spawnattr_setsigdefault
2454
2455## begin gnulib module posix_spawnattr_setsigmask
2456ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setsigmask))
2457
2458
2459EXTRA_DIST += spawnattr_setsigmask.c
2460
2461EXTRA_libgnu_a_SOURCES += spawnattr_setsigmask.c
2462
2463endif
2464## end gnulib module posix_spawnattr_setsigmask
2465
2273## begin gnulib module pselect 2466## begin gnulib module pselect
2274ifeq (,$(OMIT_GNULIB_MODULE_pselect)) 2467ifeq (,$(OMIT_GNULIB_MODULE_pselect))
2275 2468
@@ -2357,6 +2550,39 @@ EXTRA_DIST += root-uid.h
2357endif 2550endif
2358## end gnulib module root-uid 2551## end gnulib module root-uid
2359 2552
2553## begin gnulib module sched
2554ifeq (,$(OMIT_GNULIB_MODULE_sched))
2555
2556BUILT_SOURCES += sched.h
2557
2558# We need the following in order to create a replacement for <sched.h> when
2559# the system doesn't have one.
2560sched.h: sched.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
2561 $(AM_V_GEN)rm -f $@-t $@ && \
2562 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
2563 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2564 -e 's|@''HAVE_SCHED_H''@|$(HAVE_SCHED_H)|g' \
2565 -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
2566 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2567 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2568 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2569 -e 's|@''NEXT_SCHED_H''@|$(NEXT_SCHED_H)|g' \
2570 -e 's|@''HAVE_STRUCT_SCHED_PARAM''@|$(HAVE_STRUCT_SCHED_PARAM)|g' \
2571 -e 's/@''GNULIB_SCHED_YIELD''@/$(GNULIB_SCHED_YIELD)/g' \
2572 -e 's|@''HAVE_SCHED_YIELD''@|$(HAVE_SCHED_YIELD)|g' \
2573 -e 's|@''REPLACE_SCHED_YIELD''@|$(REPLACE_SCHED_YIELD)|g' \
2574 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2575 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2576 < $(srcdir)/sched.in.h; \
2577 } > $@-t && \
2578 mv $@-t $@
2579MOSTLYCLEANFILES += sched.h sched.h-t
2580
2581EXTRA_DIST += sched.in.h
2582
2583endif
2584## end gnulib module sched
2585
2360## begin gnulib module scratch_buffer 2586## begin gnulib module scratch_buffer
2361ifeq (,$(OMIT_GNULIB_MODULE_scratch_buffer)) 2587ifeq (,$(OMIT_GNULIB_MODULE_scratch_buffer))
2362 2588
@@ -2491,6 +2717,69 @@ EXTRA_DIST += warn-on-use.h
2491endif 2717endif
2492## end gnulib module snippet/warn-on-use 2718## end gnulib module snippet/warn-on-use
2493 2719
2720## begin gnulib module spawn
2721ifeq (,$(OMIT_GNULIB_MODULE_spawn))
2722
2723BUILT_SOURCES += spawn.h
2724
2725# We need the following in order to create a replacement for <spawn.h> when
2726# the system doesn't have one.
2727spawn.h: spawn.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2728 $(AM_V_GEN)rm -f $@-t $@ && \
2729 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
2730 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2731 -e 's|@''HAVE_SPAWN_H''@|$(HAVE_SPAWN_H)|g' \
2732 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2733 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2734 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2735 -e 's|@''NEXT_SPAWN_H''@|$(NEXT_SPAWN_H)|g' \
2736 -e 's/@''GNULIB_POSIX_SPAWN''@/$(GNULIB_POSIX_SPAWN)/g' \
2737 -e 's/@''GNULIB_POSIX_SPAWNP''@/$(GNULIB_POSIX_SPAWNP)/g' \
2738 -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT)/g' \
2739 -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)/g' \
2740 -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)/g' \
2741 -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)/g' \
2742 -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)/g' \
2743 -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)/g' \
2744 -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY)/g' \
2745 -e 's/@''GNULIB_POSIX_SPAWNATTR_INIT''@/$(GNULIB_POSIX_SPAWNATTR_INIT)/g' \
2746 -e 's/@''GNULIB_POSIX_SPAWNATTR_GETFLAGS''@/$(GNULIB_POSIX_SPAWNATTR_GETFLAGS)/g' \
2747 -e 's/@''GNULIB_POSIX_SPAWNATTR_SETFLAGS''@/$(GNULIB_POSIX_SPAWNATTR_SETFLAGS)/g' \
2748 -e 's/@''GNULIB_POSIX_SPAWNATTR_GETPGROUP''@/$(GNULIB_POSIX_SPAWNATTR_GETPGROUP)/g' \
2749 -e 's/@''GNULIB_POSIX_SPAWNATTR_SETPGROUP''@/$(GNULIB_POSIX_SPAWNATTR_SETPGROUP)/g' \
2750 -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM''@/$(GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM)/g' \
2751 -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM''@/$(GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM)/g' \
2752 -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY''@/$(GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY)/g' \
2753 -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY''@/$(GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY)/g' \
2754 -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT''@/$(GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT)/g' \
2755 -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT''@/$(GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT)/g' \
2756 -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSIGMASK''@/$(GNULIB_POSIX_SPAWNATTR_GETSIGMASK)/g' \
2757 -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSIGMASK''@/$(GNULIB_POSIX_SPAWNATTR_SETSIGMASK)/g' \
2758 -e 's/@''GNULIB_POSIX_SPAWNATTR_DESTROY''@/$(GNULIB_POSIX_SPAWNATTR_DESTROY)/g' \
2759 -e 's|@''HAVE_POSIX_SPAWN''@|$(HAVE_POSIX_SPAWN)|g' \
2760 -e 's|@''HAVE_POSIX_SPAWNATTR_T''@|$(HAVE_POSIX_SPAWNATTR_T)|g' \
2761 -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_T''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_T)|g' \
2762 -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \
2763 -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \
2764 -e 's|@''REPLACE_POSIX_SPAWN''@|$(REPLACE_POSIX_SPAWN)|g' \
2765 -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \
2766 -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)|g' \
2767 -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)|g' \
2768 -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \
2769 -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)|g' \
2770 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2771 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2772 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2773 < $(srcdir)/spawn.in.h; \
2774 } > $@-t && \
2775 mv $@-t $@
2776MOSTLYCLEANFILES += spawn.h spawn.h-t
2777
2778EXTRA_DIST += spawn.in.h
2779
2780endif
2781## end gnulib module spawn
2782
2494## begin gnulib module stat-time 2783## begin gnulib module stat-time
2495ifeq (,$(OMIT_GNULIB_MODULE_stat-time)) 2784ifeq (,$(OMIT_GNULIB_MODULE_stat-time))
2496 2785
@@ -2885,6 +3174,19 @@ EXTRA_libgnu_a_SOURCES += stpcpy.c
2885endif 3174endif
2886## end gnulib module stpcpy 3175## end gnulib module stpcpy
2887 3176
3177## begin gnulib module strchrnul
3178ifeq (,$(OMIT_GNULIB_MODULE_strchrnul))
3179
3180ifneq (,$(gl_GNULIB_ENABLED_strchrnul))
3181
3182endif
3183EXTRA_DIST += strchrnul.c strchrnul.valgrind
3184
3185EXTRA_libgnu_a_SOURCES += strchrnul.c
3186
3187endif
3188## end gnulib module strchrnul
3189
2888## begin gnulib module string 3190## begin gnulib module string
2889ifeq (,$(OMIT_GNULIB_MODULE_string)) 3191ifeq (,$(OMIT_GNULIB_MODULE_string))
2890 3192
diff --git a/lib/sched.in.h b/lib/sched.in.h
new file mode 100644
index 00000000000..4ee9defe82b
--- /dev/null
+++ b/lib/sched.in.h
@@ -0,0 +1,99 @@
1/* A GNU-like <sched.h>.
2 Copyright (C) 2008-2020 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _@GUARD_PREFIX@_SCHED_H
18
19#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@
21#endif
22@PRAGMA_COLUMNS@
23
24/* The include_next requires a split double-inclusion guard. */
25#if @HAVE_SCHED_H@
26# if @HAVE_SYS_CDEFS_H@
27# include <sys/cdefs.h>
28# endif
29# @INCLUDE_NEXT@ @NEXT_SCHED_H@
30#endif
31
32#ifndef _@GUARD_PREFIX@_SCHED_H
33#define _@GUARD_PREFIX@_SCHED_H
34
35/* Get pid_t.
36 This is needed on glibc 2.11 (see
37 glibc bug <https://sourceware.org/bugzilla/show_bug.cgi?id=13198>)
38 and Mac OS X 10.5. */
39#include <sys/types.h>
40
41#ifdef __KLIBC__
42/* On OS/2 kLIBC, struct sched_param is in spawn.h. */
43# include <spawn.h>
44#endif
45
46#ifdef __VMS
47/* On OpenVMS, struct sched_param is in <pthread.h>. */
48# include <pthread.h>
49#endif
50
51/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
52
53/* The definition of _GL_WARN_ON_USE is copied here. */
54
55#if !@HAVE_STRUCT_SCHED_PARAM@
56
57# if !GNULIB_defined_struct_sched_param
58struct sched_param
59{
60 int sched_priority;
61};
62# define GNULIB_defined_struct_sched_param 1
63# endif
64
65#endif
66
67#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER)
68# define SCHED_FIFO 1
69# define SCHED_RR 2
70# define SCHED_OTHER 0
71#endif
72
73#if @GNULIB_SCHED_YIELD@
74# if @REPLACE_SCHED_YIELD@
75# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
76# undef sched_yield
77# define sched_yield rpl_sched_yield
78# endif
79_GL_FUNCDECL_RPL (sched_yield, int, (void));
80_GL_CXXALIAS_RPL (sched_yield, int, (void));
81# else
82# if !@HAVE_SCHED_YIELD@
83_GL_FUNCDECL_SYS (sched_yield, int, (void));
84# endif
85_GL_CXXALIAS_SYS (sched_yield, int, (void));
86# endif
87# if __GLIBC__ >= 2
88_GL_CXXALIASWARN (sched_yield);
89# endif
90#elif defined GNULIB_POSIXCHECK
91# undef sched_yield
92# if HAVE_RAW_DECL_SCHED_YIELD
93_GL_WARN_ON_USE (sched_yield, "sched_yield is not portable - "
94 "use gnulib module sched_yield for portability");
95# endif
96#endif
97
98#endif /* _@GUARD_PREFIX@_SCHED_H */
99#endif /* _@GUARD_PREFIX@_SCHED_H */
diff --git a/lib/spawn.c b/lib/spawn.c
new file mode 100644
index 00000000000..b658453a10f
--- /dev/null
+++ b/lib/spawn.c
@@ -0,0 +1,34 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include "spawn_int.h"
23
24/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
25 Before running the process perform the actions described in FILE-ACTIONS. */
26int
27posix_spawn (pid_t *pid, const char *path,
28 const posix_spawn_file_actions_t *file_actions,
29 const posix_spawnattr_t *attrp, char *const argv[],
30 char *const envp[])
31{
32 return __spawni (pid, path, file_actions, attrp,
33 (const char * const *) argv, (const char * const *) envp, 0);
34}
diff --git a/lib/spawn.in.h b/lib/spawn.in.h
new file mode 100644
index 00000000000..537fac7dbc5
--- /dev/null
+++ b/lib/spawn.in.h
@@ -0,0 +1,974 @@
1/* Definitions for POSIX spawn interface.
2 Copyright (C) 2000, 2003-2004, 2008-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _@GUARD_PREFIX@_SPAWN_H
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23@PRAGMA_COLUMNS@
24
25/* The include_next requires a split double-inclusion guard. */
26#if @HAVE_SPAWN_H@
27# @INCLUDE_NEXT@ @NEXT_SPAWN_H@
28#endif
29
30#ifndef _@GUARD_PREFIX@_SPAWN_H
31#define _@GUARD_PREFIX@_SPAWN_H
32
33/* Get definitions of 'struct sched_param' and 'sigset_t'.
34 But avoid namespace pollution on glibc systems. */
35#if !(defined __GLIBC__ && !defined __UCLIBC__)
36# include <sched.h>
37# include <signal.h>
38#endif
39
40#include <sys/types.h>
41
42#ifndef __THROW
43# define __THROW
44#endif
45
46/* For plain 'restrict', use glibc's __restrict if defined.
47 Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have
48 "restrict", and "configure" may have defined "restrict".
49 Other compilers use __restrict, __restrict__, and _Restrict, and
50 'configure' might #define 'restrict' to those words, so pick a
51 different name. */
52#ifndef _Restrict_
53# if defined __restrict \
54 || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
55 || __clang_major__ >= 3
56# define _Restrict_ __restrict
57# elif 199901L <= __STDC_VERSION__ || defined restrict
58# define _Restrict_ restrict
59# else
60# define _Restrict_
61# endif
62#endif
63/* For the ISO C99 syntax
64 array_name[restrict]
65 use glibc's __restrict_arr if available.
66 Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode).
67 Other ISO C99 compilers support it as well. */
68#ifndef _Restrict_arr_
69# ifdef __restrict_arr
70# define _Restrict_arr_ __restrict_arr
71# elif ((199901L <= __STDC_VERSION__ \
72 || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \
73 || __clang_major__ >= 3) \
74 && !defined __cplusplus)
75# define _Restrict_arr_ _Restrict_
76# else
77# define _Restrict_arr_
78# endif
79#endif
80
81/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
82
83/* The definition of _GL_ARG_NONNULL is copied here. */
84
85/* The definition of _GL_WARN_ON_USE is copied here. */
86
87
88/* Data structure to contain attributes for thread creation. */
89#if @REPLACE_POSIX_SPAWN@ || (@HAVE_POSIX_SPAWNATTR_T@ && !@HAVE_POSIX_SPAWN@)
90# define posix_spawnattr_t rpl_posix_spawnattr_t
91#endif
92#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWNATTR_T@ || !@HAVE_POSIX_SPAWN@
93# if !GNULIB_defined_posix_spawnattr_t
94typedef struct
95{
96 short int _flags;
97 pid_t _pgrp;
98 sigset_t _sd;
99 sigset_t _ss;
100 struct sched_param _sp;
101 int _policy;
102 int __pad[16];
103} posix_spawnattr_t;
104# define GNULIB_defined_posix_spawnattr_t 1
105# endif
106#endif
107
108
109/* Data structure to contain information about the actions to be
110 performed in the new process with respect to file descriptors. */
111#if @REPLACE_POSIX_SPAWN@ || (@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ && !@HAVE_POSIX_SPAWN@)
112# define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t
113#endif
114#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ || !@HAVE_POSIX_SPAWN@
115# if !GNULIB_defined_posix_spawn_file_actions_t
116typedef struct
117{
118 int _allocated;
119 int _used;
120 struct __spawn_action *_actions;
121 int __pad[16];
122} posix_spawn_file_actions_t;
123# define GNULIB_defined_posix_spawn_file_actions_t 1
124# endif
125#endif
126
127
128/* Flags to be set in the 'posix_spawnattr_t'. */
129#if @HAVE_POSIX_SPAWN@
130/* Use the values from the system, but provide the missing ones. */
131# ifndef POSIX_SPAWN_SETSCHEDPARAM
132# define POSIX_SPAWN_SETSCHEDPARAM 0
133# endif
134# ifndef POSIX_SPAWN_SETSCHEDULER
135# define POSIX_SPAWN_SETSCHEDULER 0
136# endif
137#else
138# if @REPLACE_POSIX_SPAWN@
139/* Use the values from the system, for better compatibility. */
140/* But this implementation does not support AIX extensions. */
141# undef POSIX_SPAWN_FORK_HANDLERS
142# else
143# define POSIX_SPAWN_RESETIDS 0x01
144# define POSIX_SPAWN_SETPGROUP 0x02
145# define POSIX_SPAWN_SETSIGDEF 0x04
146# define POSIX_SPAWN_SETSIGMASK 0x08
147# define POSIX_SPAWN_SETSCHEDPARAM 0x10
148# define POSIX_SPAWN_SETSCHEDULER 0x20
149# endif
150#endif
151/* A GNU extension. Use the next free bit position. */
152#ifndef POSIX_SPAWN_USEVFORK
153# define POSIX_SPAWN_USEVFORK \
154 ((POSIX_SPAWN_RESETIDS | (POSIX_SPAWN_RESETIDS - 1) \
155 | POSIX_SPAWN_SETPGROUP | (POSIX_SPAWN_SETPGROUP - 1) \
156 | POSIX_SPAWN_SETSIGDEF | (POSIX_SPAWN_SETSIGDEF - 1) \
157 | POSIX_SPAWN_SETSIGMASK | (POSIX_SPAWN_SETSIGMASK - 1) \
158 | POSIX_SPAWN_SETSCHEDPARAM \
159 | (POSIX_SPAWN_SETSCHEDPARAM > 0 ? POSIX_SPAWN_SETSCHEDPARAM - 1 : 0) \
160 | POSIX_SPAWN_SETSCHEDULER \
161 | (POSIX_SPAWN_SETSCHEDULER > 0 ? POSIX_SPAWN_SETSCHEDULER - 1 : 0)) \
162 + 1)
163#endif
164#if !GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap
165typedef int verify_POSIX_SPAWN_USEVFORK_no_overlap
166 [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP
167 | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK
168 | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER)
169 & POSIX_SPAWN_USEVFORK)
170 == 0)
171 ? 1 : -1];
172# define GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap 1
173#endif
174
175
176#if @GNULIB_POSIX_SPAWN@
177/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
178 Before running the process perform the actions described in FILE-ACTIONS.
179
180 This function is a possible cancellation points and therefore not
181 marked with __THROW. */
182# if @REPLACE_POSIX_SPAWN@
183# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184# define posix_spawn rpl_posix_spawn
185# endif
186_GL_FUNCDECL_RPL (posix_spawn, int,
187 (pid_t *_Restrict_ __pid,
188 const char *_Restrict_ __path,
189 const posix_spawn_file_actions_t *_Restrict_ __file_actions,
190 const posix_spawnattr_t *_Restrict_ __attrp,
191 char *const argv[_Restrict_arr_],
192 char *const envp[_Restrict_arr_])
193 _GL_ARG_NONNULL ((2, 5, 6)));
194_GL_CXXALIAS_RPL (posix_spawn, int,
195 (pid_t *_Restrict_ __pid,
196 const char *_Restrict_ __path,
197 const posix_spawn_file_actions_t *_Restrict_ __file_actions,
198 const posix_spawnattr_t *_Restrict_ __attrp,
199 char *const argv[_Restrict_arr_],
200 char *const envp[_Restrict_arr_]));
201# else
202# if !@HAVE_POSIX_SPAWN@
203_GL_FUNCDECL_SYS (posix_spawn, int,
204 (pid_t *_Restrict_ __pid,
205 const char *_Restrict_ __path,
206 const posix_spawn_file_actions_t *_Restrict_ __file_actions,
207 const posix_spawnattr_t *_Restrict_ __attrp,
208 char *const argv[_Restrict_arr_],
209 char *const envp[_Restrict_arr_])
210 _GL_ARG_NONNULL ((2, 5, 6)));
211# endif
212_GL_CXXALIAS_SYS (posix_spawn, int,
213 (pid_t *_Restrict_ __pid,
214 const char *_Restrict_ __path,
215 const posix_spawn_file_actions_t *_Restrict_ __file_actions,
216 const posix_spawnattr_t *_Restrict_ __attrp,
217 char *const argv[_Restrict_arr_],
218 char *const envp[_Restrict_arr_]));
219# endif
220_GL_CXXALIASWARN (posix_spawn);
221#elif defined GNULIB_POSIXCHECK
222# undef posix_spawn
223# if HAVE_RAW_DECL_POSIX_SPAWN
224_GL_WARN_ON_USE (posix_spawn, "posix_spawn is unportable - "
225 "use gnulib module posix_spawn for portability");
226# endif
227#endif
228
229#if @GNULIB_POSIX_SPAWNP@
230/* Similar to 'posix_spawn' but search for FILE in the PATH.
231
232 This function is a possible cancellation points and therefore not
233 marked with __THROW. */
234# if @REPLACE_POSIX_SPAWN@
235# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
236# define posix_spawnp rpl_posix_spawnp
237# endif
238_GL_FUNCDECL_RPL (posix_spawnp, int,
239 (pid_t *__pid, const char *__file,
240 const posix_spawn_file_actions_t *__file_actions,
241 const posix_spawnattr_t *__attrp,
242 char *const argv[], char *const envp[])
243 _GL_ARG_NONNULL ((2, 5, 6)));
244_GL_CXXALIAS_RPL (posix_spawnp, int,
245 (pid_t *__pid, const char *__file,
246 const posix_spawn_file_actions_t *__file_actions,
247 const posix_spawnattr_t *__attrp,
248 char *const argv[], char *const envp[]));
249# else
250# if !@HAVE_POSIX_SPAWN@
251_GL_FUNCDECL_SYS (posix_spawnp, int,
252 (pid_t *__pid, const char *__file,
253 const posix_spawn_file_actions_t *__file_actions,
254 const posix_spawnattr_t *__attrp,
255 char *const argv[], char *const envp[])
256 _GL_ARG_NONNULL ((2, 5, 6)));
257# endif
258_GL_CXXALIAS_SYS (posix_spawnp, int,
259 (pid_t *__pid, const char *__file,
260 const posix_spawn_file_actions_t *__file_actions,
261 const posix_spawnattr_t *__attrp,
262 char *const argv[], char *const envp[]));
263# endif
264_GL_CXXALIASWARN (posix_spawnp);
265#elif defined GNULIB_POSIXCHECK
266# undef posix_spawnp
267# if HAVE_RAW_DECL_POSIX_SPAWNP
268_GL_WARN_ON_USE (posix_spawnp, "posix_spawnp is unportable - "
269 "use gnulib module posix_spawnp for portability");
270# endif
271#endif
272
273
274#if @GNULIB_POSIX_SPAWNATTR_INIT@
275/* Initialize data structure with attributes for 'spawn' to default values. */
276# if @REPLACE_POSIX_SPAWN@
277# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
278# define posix_spawnattr_init rpl_posix_spawnattr_init
279# endif
280_GL_FUNCDECL_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
281 __THROW _GL_ARG_NONNULL ((1)));
282_GL_CXXALIAS_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
283# else
284# if !@HAVE_POSIX_SPAWN@
285_GL_FUNCDECL_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
286 __THROW _GL_ARG_NONNULL ((1)));
287# endif
288_GL_CXXALIAS_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
289# endif
290_GL_CXXALIASWARN (posix_spawnattr_init);
291#elif defined GNULIB_POSIXCHECK
292# undef posix_spawnattr_init
293# if HAVE_RAW_DECL_POSIX_SPAWNATTR_INIT
294_GL_WARN_ON_USE (posix_spawnattr_init, "posix_spawnattr_init is unportable - "
295 "use gnulib module posix_spawnattr_init for portability");
296# endif
297#endif
298
299#if @GNULIB_POSIX_SPAWNATTR_DESTROY@
300/* Free resources associated with ATTR. */
301# if @REPLACE_POSIX_SPAWN@
302# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
303# define posix_spawnattr_destroy rpl_posix_spawnattr_destroy
304# endif
305_GL_FUNCDECL_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
306 __THROW _GL_ARG_NONNULL ((1)));
307_GL_CXXALIAS_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
308# else
309# if !@HAVE_POSIX_SPAWN@
310_GL_FUNCDECL_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
311 __THROW _GL_ARG_NONNULL ((1)));
312# endif
313_GL_CXXALIAS_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
314# endif
315_GL_CXXALIASWARN (posix_spawnattr_destroy);
316#elif defined GNULIB_POSIXCHECK
317# undef posix_spawnattr_destroy
318# if HAVE_RAW_DECL_POSIX_SPAWNATTR_DESTROY
319_GL_WARN_ON_USE (posix_spawnattr_destroy,
320 "posix_spawnattr_destroy is unportable - "
321 "use gnulib module posix_spawnattr_destroy for portability");
322# endif
323#endif
324
325#if @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@
326/* Store signal mask for signals with default handling from ATTR in
327 SIGDEFAULT. */
328# if @REPLACE_POSIX_SPAWN@
329# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
330# define posix_spawnattr_getsigdefault rpl_posix_spawnattr_getsigdefault
331# endif
332_GL_FUNCDECL_RPL (posix_spawnattr_getsigdefault, int,
333 (const posix_spawnattr_t *_Restrict_ __attr,
334 sigset_t *_Restrict_ __sigdefault)
335 __THROW _GL_ARG_NONNULL ((1, 2)));
336_GL_CXXALIAS_RPL (posix_spawnattr_getsigdefault, int,
337 (const posix_spawnattr_t *_Restrict_ __attr,
338 sigset_t *_Restrict_ __sigdefault));
339# else
340# if !@HAVE_POSIX_SPAWN@
341_GL_FUNCDECL_SYS (posix_spawnattr_getsigdefault, int,
342 (const posix_spawnattr_t *_Restrict_ __attr,
343 sigset_t *_Restrict_ __sigdefault)
344 __THROW _GL_ARG_NONNULL ((1, 2)));
345# endif
346_GL_CXXALIAS_SYS (posix_spawnattr_getsigdefault, int,
347 (const posix_spawnattr_t *_Restrict_ __attr,
348 sigset_t *_Restrict_ __sigdefault));
349# endif
350_GL_CXXALIASWARN (posix_spawnattr_getsigdefault);
351#elif defined GNULIB_POSIXCHECK
352# undef posix_spawnattr_getsigdefault
353# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGDEFAULT
354_GL_WARN_ON_USE (posix_spawnattr_getsigdefault,
355 "posix_spawnattr_getsigdefault is unportable - "
356 "use gnulib module posix_spawnattr_getsigdefault for portability");
357# endif
358#endif
359
360#if @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@
361/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
362# if @REPLACE_POSIX_SPAWN@
363# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
364# define posix_spawnattr_setsigdefault rpl_posix_spawnattr_setsigdefault
365# endif
366_GL_FUNCDECL_RPL (posix_spawnattr_setsigdefault, int,
367 (posix_spawnattr_t *_Restrict_ __attr,
368 const sigset_t *_Restrict_ __sigdefault)
369 __THROW _GL_ARG_NONNULL ((1, 2)));
370_GL_CXXALIAS_RPL (posix_spawnattr_setsigdefault, int,
371 (posix_spawnattr_t *_Restrict_ __attr,
372 const sigset_t *_Restrict_ __sigdefault));
373# else
374# if !@HAVE_POSIX_SPAWN@
375_GL_FUNCDECL_SYS (posix_spawnattr_setsigdefault, int,
376 (posix_spawnattr_t *_Restrict_ __attr,
377 const sigset_t *_Restrict_ __sigdefault)
378 __THROW _GL_ARG_NONNULL ((1, 2)));
379# endif
380_GL_CXXALIAS_SYS (posix_spawnattr_setsigdefault, int,
381 (posix_spawnattr_t *_Restrict_ __attr,
382 const sigset_t *_Restrict_ __sigdefault));
383# endif
384_GL_CXXALIASWARN (posix_spawnattr_setsigdefault);
385#elif defined GNULIB_POSIXCHECK
386# undef posix_spawnattr_setsigdefault
387# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGDEFAULT
388_GL_WARN_ON_USE (posix_spawnattr_setsigdefault,
389 "posix_spawnattr_setsigdefault is unportable - "
390 "use gnulib module posix_spawnattr_setsigdefault for portability");
391# endif
392#endif
393
394#if @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@
395/* Store signal mask for the new process from ATTR in SIGMASK. */
396# if @REPLACE_POSIX_SPAWN@
397# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
398# define posix_spawnattr_getsigmask rpl_posix_spawnattr_getsigmask
399# endif
400_GL_FUNCDECL_RPL (posix_spawnattr_getsigmask, int,
401 (const posix_spawnattr_t *_Restrict_ __attr,
402 sigset_t *_Restrict_ __sigmask)
403 __THROW _GL_ARG_NONNULL ((1, 2)));
404_GL_CXXALIAS_RPL (posix_spawnattr_getsigmask, int,
405 (const posix_spawnattr_t *_Restrict_ __attr,
406 sigset_t *_Restrict_ __sigmask));
407# else
408# if !@HAVE_POSIX_SPAWN@
409_GL_FUNCDECL_SYS (posix_spawnattr_getsigmask, int,
410 (const posix_spawnattr_t *_Restrict_ __attr,
411 sigset_t *_Restrict_ __sigmask)
412 __THROW _GL_ARG_NONNULL ((1, 2)));
413# endif
414_GL_CXXALIAS_SYS (posix_spawnattr_getsigmask, int,
415 (const posix_spawnattr_t *_Restrict_ __attr,
416 sigset_t *_Restrict_ __sigmask));
417# endif
418_GL_CXXALIASWARN (posix_spawnattr_getsigmask);
419#elif defined GNULIB_POSIXCHECK
420# undef posix_spawnattr_getsigmask
421# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGMASK
422_GL_WARN_ON_USE (posix_spawnattr_getsigmask,
423 "posix_spawnattr_getsigmask is unportable - "
424 "use gnulib module posix_spawnattr_getsigmask for portability");
425# endif
426#endif
427
428#if @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@
429/* Set signal mask for the new process in ATTR to SIGMASK. */
430# if @REPLACE_POSIX_SPAWN@
431# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
432# define posix_spawnattr_setsigmask rpl_posix_spawnattr_setsigmask
433# endif
434_GL_FUNCDECL_RPL (posix_spawnattr_setsigmask, int,
435 (posix_spawnattr_t *_Restrict_ __attr,
436 const sigset_t *_Restrict_ __sigmask)
437 __THROW _GL_ARG_NONNULL ((1, 2)));
438_GL_CXXALIAS_RPL (posix_spawnattr_setsigmask, int,
439 (posix_spawnattr_t *_Restrict_ __attr,
440 const sigset_t *_Restrict_ __sigmask));
441# else
442# if !@HAVE_POSIX_SPAWN@
443_GL_FUNCDECL_SYS (posix_spawnattr_setsigmask, int,
444 (posix_spawnattr_t *_Restrict_ __attr,
445 const sigset_t *_Restrict_ __sigmask)
446 __THROW _GL_ARG_NONNULL ((1, 2)));
447# endif
448_GL_CXXALIAS_SYS (posix_spawnattr_setsigmask, int,
449 (posix_spawnattr_t *_Restrict_ __attr,
450 const sigset_t *_Restrict_ __sigmask));
451# endif
452_GL_CXXALIASWARN (posix_spawnattr_setsigmask);
453#elif defined GNULIB_POSIXCHECK
454# undef posix_spawnattr_setsigmask
455# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGMASK
456_GL_WARN_ON_USE (posix_spawnattr_setsigmask,
457 "posix_spawnattr_setsigmask is unportable - "
458 "use gnulib module posix_spawnattr_setsigmask for portability");
459# endif
460#endif
461
462#if @GNULIB_POSIX_SPAWNATTR_GETFLAGS@
463/* Get flag word from the attribute structure. */
464# if @REPLACE_POSIX_SPAWN@
465# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
466# define posix_spawnattr_getflags rpl_posix_spawnattr_getflags
467# endif
468_GL_FUNCDECL_RPL (posix_spawnattr_getflags, int,
469 (const posix_spawnattr_t *_Restrict_ __attr,
470 short int *_Restrict_ __flags)
471 __THROW _GL_ARG_NONNULL ((1, 2)));
472_GL_CXXALIAS_RPL (posix_spawnattr_getflags, int,
473 (const posix_spawnattr_t *_Restrict_ __attr,
474 short int *_Restrict_ __flags));
475# else
476# if !@HAVE_POSIX_SPAWN@
477_GL_FUNCDECL_SYS (posix_spawnattr_getflags, int,
478 (const posix_spawnattr_t *_Restrict_ __attr,
479 short int *_Restrict_ __flags)
480 __THROW _GL_ARG_NONNULL ((1, 2)));
481# endif
482_GL_CXXALIAS_SYS (posix_spawnattr_getflags, int,
483 (const posix_spawnattr_t *_Restrict_ __attr,
484 short int *_Restrict_ __flags));
485# endif
486_GL_CXXALIASWARN (posix_spawnattr_getflags);
487#elif defined GNULIB_POSIXCHECK
488# undef posix_spawnattr_getflags
489# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETFLAGS
490_GL_WARN_ON_USE (posix_spawnattr_getflags,
491 "posix_spawnattr_getflags is unportable - "
492 "use gnulib module posix_spawnattr_getflags for portability");
493# endif
494#endif
495
496#if @GNULIB_POSIX_SPAWNATTR_SETFLAGS@
497/* Store flags in the attribute structure. */
498# if @REPLACE_POSIX_SPAWN@
499# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
500# define posix_spawnattr_setflags rpl_posix_spawnattr_setflags
501# endif
502_GL_FUNCDECL_RPL (posix_spawnattr_setflags, int,
503 (posix_spawnattr_t *__attr, short int __flags)
504 __THROW _GL_ARG_NONNULL ((1)));
505_GL_CXXALIAS_RPL (posix_spawnattr_setflags, int,
506 (posix_spawnattr_t *__attr, short int __flags));
507# else
508# if !@HAVE_POSIX_SPAWN@
509_GL_FUNCDECL_SYS (posix_spawnattr_setflags, int,
510 (posix_spawnattr_t *__attr, short int __flags)
511 __THROW _GL_ARG_NONNULL ((1)));
512# endif
513_GL_CXXALIAS_SYS (posix_spawnattr_setflags, int,
514 (posix_spawnattr_t *__attr, short int __flags));
515# endif
516_GL_CXXALIASWARN (posix_spawnattr_setflags);
517#elif defined GNULIB_POSIXCHECK
518# undef posix_spawnattr_setflags
519# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETFLAGS
520_GL_WARN_ON_USE (posix_spawnattr_setflags,
521 "posix_spawnattr_setflags is unportable - "
522 "use gnulib module posix_spawnattr_setflags for portability");
523# endif
524#endif
525
526#if @GNULIB_POSIX_SPAWNATTR_GETPGROUP@
527/* Get process group ID from the attribute structure. */
528# if @REPLACE_POSIX_SPAWN@
529# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
530# define posix_spawnattr_getpgroup rpl_posix_spawnattr_getpgroup
531# endif
532_GL_FUNCDECL_RPL (posix_spawnattr_getpgroup, int,
533 (const posix_spawnattr_t *_Restrict_ __attr,
534 pid_t *_Restrict_ __pgroup)
535 __THROW _GL_ARG_NONNULL ((1, 2)));
536_GL_CXXALIAS_RPL (posix_spawnattr_getpgroup, int,
537 (const posix_spawnattr_t *_Restrict_ __attr,
538 pid_t *_Restrict_ __pgroup));
539# else
540# if !@HAVE_POSIX_SPAWN@
541_GL_FUNCDECL_SYS (posix_spawnattr_getpgroup, int,
542 (const posix_spawnattr_t *_Restrict_ __attr,
543 pid_t *_Restrict_ __pgroup)
544 __THROW _GL_ARG_NONNULL ((1, 2)));
545# endif
546_GL_CXXALIAS_SYS (posix_spawnattr_getpgroup, int,
547 (const posix_spawnattr_t *_Restrict_ __attr,
548 pid_t *_Restrict_ __pgroup));
549# endif
550_GL_CXXALIASWARN (posix_spawnattr_getpgroup);
551#elif defined GNULIB_POSIXCHECK
552# undef posix_spawnattr_getpgroup
553# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETPGROUP
554_GL_WARN_ON_USE (posix_spawnattr_getpgroup,
555 "posix_spawnattr_getpgroup is unportable - "
556 "use gnulib module posix_spawnattr_getpgroup for portability");
557# endif
558#endif
559
560#if @GNULIB_POSIX_SPAWNATTR_SETPGROUP@
561/* Store process group ID in the attribute structure. */
562# if @REPLACE_POSIX_SPAWN@
563# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
564# define posix_spawnattr_setpgroup rpl_posix_spawnattr_setpgroup
565# endif
566_GL_FUNCDECL_RPL (posix_spawnattr_setpgroup, int,
567 (posix_spawnattr_t *__attr, pid_t __pgroup)
568 __THROW _GL_ARG_NONNULL ((1)));
569_GL_CXXALIAS_RPL (posix_spawnattr_setpgroup, int,
570 (posix_spawnattr_t *__attr, pid_t __pgroup));
571# else
572# if !@HAVE_POSIX_SPAWN@
573_GL_FUNCDECL_SYS (posix_spawnattr_setpgroup, int,
574 (posix_spawnattr_t *__attr, pid_t __pgroup)
575 __THROW _GL_ARG_NONNULL ((1)));
576# endif
577_GL_CXXALIAS_SYS (posix_spawnattr_setpgroup, int,
578 (posix_spawnattr_t *__attr, pid_t __pgroup));
579# endif
580_GL_CXXALIASWARN (posix_spawnattr_setpgroup);
581#elif defined GNULIB_POSIXCHECK
582# undef posix_spawnattr_setpgroup
583# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETPGROUP
584_GL_WARN_ON_USE (posix_spawnattr_setpgroup,
585 "posix_spawnattr_setpgroup is unportable - "
586 "use gnulib module posix_spawnattr_setpgroup for portability");
587# endif
588#endif
589
590#if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@
591/* Get scheduling policy from the attribute structure. */
592# if @REPLACE_POSIX_SPAWN@
593# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
594# define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy
595# endif
596_GL_FUNCDECL_RPL (posix_spawnattr_getschedpolicy, int,
597 (const posix_spawnattr_t *_Restrict_ __attr,
598 int *_Restrict_ __schedpolicy)
599 __THROW _GL_ARG_NONNULL ((1, 2)));
600_GL_CXXALIAS_RPL (posix_spawnattr_getschedpolicy, int,
601 (const posix_spawnattr_t *_Restrict_ __attr,
602 int *_Restrict_ __schedpolicy));
603# else
604# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0
605_GL_FUNCDECL_SYS (posix_spawnattr_getschedpolicy, int,
606 (const posix_spawnattr_t *_Restrict_ __attr,
607 int *_Restrict_ __schedpolicy)
608 __THROW _GL_ARG_NONNULL ((1, 2)));
609# endif
610_GL_CXXALIAS_SYS (posix_spawnattr_getschedpolicy, int,
611 (const posix_spawnattr_t *_Restrict_ __attr,
612 int *_Restrict_ __schedpolicy));
613# endif
614# if __GLIBC__ >= 2
615_GL_CXXALIASWARN (posix_spawnattr_getschedpolicy);
616# endif
617#elif defined GNULIB_POSIXCHECK
618# undef posix_spawnattr_getschedpolicy
619# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPOLICY
620_GL_WARN_ON_USE (posix_spawnattr_getschedpolicy,
621 "posix_spawnattr_getschedpolicy is unportable - "
622 "use gnulib module posix_spawnattr_getschedpolicy for portability");
623# endif
624#endif
625
626#if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@
627/* Store scheduling policy in the attribute structure. */
628# if @REPLACE_POSIX_SPAWN@
629# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
630# define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy
631# endif
632_GL_FUNCDECL_RPL (posix_spawnattr_setschedpolicy, int,
633 (posix_spawnattr_t *__attr, int __schedpolicy)
634 __THROW _GL_ARG_NONNULL ((1)));
635_GL_CXXALIAS_RPL (posix_spawnattr_setschedpolicy, int,
636 (posix_spawnattr_t *__attr, int __schedpolicy));
637# else
638# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0
639_GL_FUNCDECL_SYS (posix_spawnattr_setschedpolicy, int,
640 (posix_spawnattr_t *__attr, int __schedpolicy)
641 __THROW _GL_ARG_NONNULL ((1)));
642# endif
643_GL_CXXALIAS_SYS (posix_spawnattr_setschedpolicy, int,
644 (posix_spawnattr_t *__attr, int __schedpolicy));
645# endif
646# if __GLIBC__ >= 2
647_GL_CXXALIASWARN (posix_spawnattr_setschedpolicy);
648# endif
649#elif defined GNULIB_POSIXCHECK
650# undef posix_spawnattr_setschedpolicy
651# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPOLICY
652_GL_WARN_ON_USE (posix_spawnattr_setschedpolicy,
653 "posix_spawnattr_setschedpolicy is unportable - "
654 "use gnulib module posix_spawnattr_setschedpolicy for portability");
655# endif
656#endif
657
658#if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@
659/* Get scheduling parameters from the attribute structure. */
660# if @REPLACE_POSIX_SPAWN@
661# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
662# define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam
663# endif
664_GL_FUNCDECL_RPL (posix_spawnattr_getschedparam, int,
665 (const posix_spawnattr_t *_Restrict_ __attr,
666 struct sched_param *_Restrict_ __schedparam)
667 __THROW _GL_ARG_NONNULL ((1, 2)));
668_GL_CXXALIAS_RPL (posix_spawnattr_getschedparam, int,
669 (const posix_spawnattr_t *_Restrict_ __attr,
670 struct sched_param *_Restrict_ __schedparam));
671# else
672# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0
673_GL_FUNCDECL_SYS (posix_spawnattr_getschedparam, int,
674 (const posix_spawnattr_t *_Restrict_ __attr,
675 struct sched_param *_Restrict_ __schedparam)
676 __THROW _GL_ARG_NONNULL ((1, 2)));
677# endif
678_GL_CXXALIAS_SYS (posix_spawnattr_getschedparam, int,
679 (const posix_spawnattr_t *_Restrict_ __attr,
680 struct sched_param *_Restrict_ __schedparam));
681# endif
682# if __GLIBC__ >= 2
683_GL_CXXALIASWARN (posix_spawnattr_getschedparam);
684# endif
685#elif defined GNULIB_POSIXCHECK
686# undef posix_spawnattr_getschedparam
687# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPARAM
688_GL_WARN_ON_USE (posix_spawnattr_getschedparam,
689 "posix_spawnattr_getschedparam is unportable - "
690 "use gnulib module posix_spawnattr_getschedparam for portability");
691# endif
692#endif
693
694#if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@
695/* Store scheduling parameters in the attribute structure. */
696# if @REPLACE_POSIX_SPAWN@
697# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
698# define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam
699# endif
700_GL_FUNCDECL_RPL (posix_spawnattr_setschedparam, int,
701 (posix_spawnattr_t *_Restrict_ __attr,
702 const struct sched_param *_Restrict_ __schedparam)
703 __THROW _GL_ARG_NONNULL ((1, 2)));
704_GL_CXXALIAS_RPL (posix_spawnattr_setschedparam, int,
705 (posix_spawnattr_t *_Restrict_ __attr,
706 const struct sched_param *_Restrict_ __schedparam));
707# else
708# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0
709_GL_FUNCDECL_SYS (posix_spawnattr_setschedparam, int,
710 (posix_spawnattr_t *_Restrict_ __attr,
711 const struct sched_param *_Restrict_ __schedparam)
712 __THROW _GL_ARG_NONNULL ((1, 2)));
713# endif
714_GL_CXXALIAS_SYS (posix_spawnattr_setschedparam, int,
715 (posix_spawnattr_t *_Restrict_ __attr,
716 const struct sched_param *_Restrict_ __schedparam));
717# endif
718# if __GLIBC__ >= 2
719_GL_CXXALIASWARN (posix_spawnattr_setschedparam);
720# endif
721#elif defined GNULIB_POSIXCHECK
722# undef posix_spawnattr_setschedparam
723# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPARAM
724_GL_WARN_ON_USE (posix_spawnattr_setschedparam,
725 "posix_spawnattr_setschedparam is unportable - "
726 "use gnulib module posix_spawnattr_setschedparam for portability");
727# endif
728#endif
729
730
731#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@
732/* Initialize data structure for file attribute for 'spawn' call. */
733# if @REPLACE_POSIX_SPAWN@
734# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
735# define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init
736# endif
737_GL_FUNCDECL_RPL (posix_spawn_file_actions_init, int,
738 (posix_spawn_file_actions_t *__file_actions)
739 __THROW _GL_ARG_NONNULL ((1)));
740_GL_CXXALIAS_RPL (posix_spawn_file_actions_init, int,
741 (posix_spawn_file_actions_t *__file_actions));
742# else
743# if !@HAVE_POSIX_SPAWN@
744_GL_FUNCDECL_SYS (posix_spawn_file_actions_init, int,
745 (posix_spawn_file_actions_t *__file_actions)
746 __THROW _GL_ARG_NONNULL ((1)));
747# endif
748_GL_CXXALIAS_SYS (posix_spawn_file_actions_init, int,
749 (posix_spawn_file_actions_t *__file_actions));
750# endif
751_GL_CXXALIASWARN (posix_spawn_file_actions_init);
752#elif defined GNULIB_POSIXCHECK
753# undef posix_spawn_file_actions_init
754# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_INIT
755_GL_WARN_ON_USE (posix_spawn_file_actions_init,
756 "posix_spawn_file_actions_init is unportable - "
757 "use gnulib module posix_spawn_file_actions_init for portability");
758# endif
759#endif
760
761#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@
762/* Free resources associated with FILE-ACTIONS. */
763# if @REPLACE_POSIX_SPAWN@
764# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
765# define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy
766# endif
767_GL_FUNCDECL_RPL (posix_spawn_file_actions_destroy, int,
768 (posix_spawn_file_actions_t *__file_actions)
769 __THROW _GL_ARG_NONNULL ((1)));
770_GL_CXXALIAS_RPL (posix_spawn_file_actions_destroy, int,
771 (posix_spawn_file_actions_t *__file_actions));
772# else
773# if !@HAVE_POSIX_SPAWN@
774_GL_FUNCDECL_SYS (posix_spawn_file_actions_destroy, int,
775 (posix_spawn_file_actions_t *__file_actions)
776 __THROW _GL_ARG_NONNULL ((1)));
777# endif
778_GL_CXXALIAS_SYS (posix_spawn_file_actions_destroy, int,
779 (posix_spawn_file_actions_t *__file_actions));
780# endif
781_GL_CXXALIASWARN (posix_spawn_file_actions_destroy);
782#elif defined GNULIB_POSIXCHECK
783# undef posix_spawn_file_actions_destroy
784# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_DESTROY
785_GL_WARN_ON_USE (posix_spawn_file_actions_destroy,
786 "posix_spawn_file_actions_destroy is unportable - "
787 "use gnulib module posix_spawn_file_actions_destroy for portability");
788# endif
789#endif
790
791#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
792/* Add an action to FILE-ACTIONS which tells the implementation to call
793 'open' for the given file during the 'spawn' call. */
794# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
795# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
796# define posix_spawn_file_actions_addopen rpl_posix_spawn_file_actions_addopen
797# endif
798_GL_FUNCDECL_RPL (posix_spawn_file_actions_addopen, int,
799 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
800 int __fd,
801 const char *_Restrict_ __path, int __oflag, mode_t __mode)
802 __THROW _GL_ARG_NONNULL ((1, 3)));
803_GL_CXXALIAS_RPL (posix_spawn_file_actions_addopen, int,
804 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
805 int __fd,
806 const char *_Restrict_ __path, int __oflag, mode_t __mode));
807# else
808# if !@HAVE_POSIX_SPAWN@
809_GL_FUNCDECL_SYS (posix_spawn_file_actions_addopen, int,
810 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
811 int __fd,
812 const char *_Restrict_ __path, int __oflag, mode_t __mode)
813 __THROW _GL_ARG_NONNULL ((1, 3)));
814# endif
815_GL_CXXALIAS_SYS (posix_spawn_file_actions_addopen, int,
816 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
817 int __fd,
818 const char *_Restrict_ __path, int __oflag, mode_t __mode));
819# endif
820# if __GLIBC__ >= 2
821_GL_CXXALIASWARN (posix_spawn_file_actions_addopen);
822# endif
823#elif defined GNULIB_POSIXCHECK
824# undef posix_spawn_file_actions_addopen
825# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN
826_GL_WARN_ON_USE (posix_spawn_file_actions_addopen,
827 "posix_spawn_file_actions_addopen is unportable - "
828 "use gnulib module posix_spawn_file_actions_addopen for portability");
829# endif
830#endif
831
832#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
833/* Add an action to FILE-ACTIONS which tells the implementation to call
834 'close' for the given file descriptor during the 'spawn' call. */
835# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
836# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
837# define posix_spawn_file_actions_addclose rpl_posix_spawn_file_actions_addclose
838# endif
839_GL_FUNCDECL_RPL (posix_spawn_file_actions_addclose, int,
840 (posix_spawn_file_actions_t *__file_actions, int __fd)
841 __THROW _GL_ARG_NONNULL ((1)));
842_GL_CXXALIAS_RPL (posix_spawn_file_actions_addclose, int,
843 (posix_spawn_file_actions_t *__file_actions, int __fd));
844# else
845# if !@HAVE_POSIX_SPAWN@
846_GL_FUNCDECL_SYS (posix_spawn_file_actions_addclose, int,
847 (posix_spawn_file_actions_t *__file_actions, int __fd)
848 __THROW _GL_ARG_NONNULL ((1)));
849# endif
850_GL_CXXALIAS_SYS (posix_spawn_file_actions_addclose, int,
851 (posix_spawn_file_actions_t *__file_actions, int __fd));
852# endif
853# if __GLIBC__ >= 2
854_GL_CXXALIASWARN (posix_spawn_file_actions_addclose);
855# endif
856#elif defined GNULIB_POSIXCHECK
857# undef posix_spawn_file_actions_addclose
858# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE
859_GL_WARN_ON_USE (posix_spawn_file_actions_addclose,
860 "posix_spawn_file_actions_addclose is unportable - "
861 "use gnulib module posix_spawn_file_actions_addclose for portability");
862# endif
863#endif
864
865#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
866/* Add an action to FILE-ACTIONS which tells the implementation to call
867 'dup2' for the given file descriptors during the 'spawn' call. */
868# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
869# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
870# define posix_spawn_file_actions_adddup2 rpl_posix_spawn_file_actions_adddup2
871# endif
872_GL_FUNCDECL_RPL (posix_spawn_file_actions_adddup2, int,
873 (posix_spawn_file_actions_t *__file_actions,
874 int __fd, int __newfd)
875 __THROW _GL_ARG_NONNULL ((1)));
876_GL_CXXALIAS_RPL (posix_spawn_file_actions_adddup2, int,
877 (posix_spawn_file_actions_t *__file_actions,
878 int __fd, int __newfd));
879# else
880# if !@HAVE_POSIX_SPAWN@
881_GL_FUNCDECL_SYS (posix_spawn_file_actions_adddup2, int,
882 (posix_spawn_file_actions_t *__file_actions,
883 int __fd, int __newfd)
884 __THROW _GL_ARG_NONNULL ((1)));
885# endif
886_GL_CXXALIAS_SYS (posix_spawn_file_actions_adddup2, int,
887 (posix_spawn_file_actions_t *__file_actions,
888 int __fd, int __newfd));
889# endif
890# if __GLIBC__ >= 2
891_GL_CXXALIASWARN (posix_spawn_file_actions_adddup2);
892# endif
893#elif defined GNULIB_POSIXCHECK
894# undef posix_spawn_file_actions_adddup2
895# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2
896_GL_WARN_ON_USE (posix_spawn_file_actions_adddup2,
897 "posix_spawn_file_actions_adddup2 is unportable - "
898 "use gnulib module posix_spawn_file_actions_adddup2 for portability");
899# endif
900#endif
901
902#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
903/* Add an action to FILE-ACTIONS which tells the implementation to call
904 'chdir' to the given directory during the 'spawn' call. */
905# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
906# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
907# define posix_spawn_file_actions_addchdir rpl_posix_spawn_file_actions_addchdir
908# endif
909_GL_FUNCDECL_RPL (posix_spawn_file_actions_addchdir, int,
910 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
911 const char *_Restrict_ __path)
912 __THROW _GL_ARG_NONNULL ((1, 2)));
913_GL_CXXALIAS_RPL (posix_spawn_file_actions_addchdir, int,
914 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
915 const char *_Restrict_ __path));
916# else
917# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
918_GL_FUNCDECL_SYS (posix_spawn_file_actions_addchdir, int,
919 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
920 const char *_Restrict_ __path)
921 __THROW _GL_ARG_NONNULL ((1, 2)));
922# endif
923_GL_CXXALIAS_SYS (posix_spawn_file_actions_addchdir, int,
924 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
925 const char *_Restrict_ __path));
926# endif
927_GL_CXXALIASWARN (posix_spawn_file_actions_addchdir);
928#elif defined GNULIB_POSIXCHECK
929# undef posix_spawn_file_actions_addchdir
930# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
931_GL_WARN_ON_USE (posix_spawn_file_actions_addchdir,
932 "posix_spawn_file_actions_addchdir is unportable - "
933 "use gnulib module posix_spawn_file_actions_addchdir for portability");
934# endif
935#endif
936
937#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
938/* Add an action to FILE-ACTIONS which tells the implementation to call
939 'fchdir' to the given directory during the 'spawn' call. */
940# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
941# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
942# define posix_spawn_file_actions_addfchdir rpl_posix_spawn_file_actions_addfchdir
943# endif
944_GL_FUNCDECL_RPL (posix_spawn_file_actions_addfchdir, int,
945 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
946 int __fd)
947 __THROW _GL_ARG_NONNULL ((1)));
948_GL_CXXALIAS_RPL (posix_spawn_file_actions_addfchdir, int,
949 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
950 int __fd));
951# else
952# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
953_GL_FUNCDECL_SYS (posix_spawn_file_actions_addfchdir, int,
954 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
955 int __fd)
956 __THROW _GL_ARG_NONNULL ((1)));
957# endif
958_GL_CXXALIAS_SYS (posix_spawn_file_actions_addfchdir, int,
959 (posix_spawn_file_actions_t *_Restrict_ __file_actions,
960 int __fd));
961# endif
962_GL_CXXALIASWARN (posix_spawn_file_actions_addfchdir);
963#elif defined GNULIB_POSIXCHECK
964# undef posix_spawn_file_actions_addfchdir
965# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR
966_GL_WARN_ON_USE (posix_spawn_file_actions_addfchdir,
967 "posix_spawn_file_actions_addfchdir is unportable - "
968 "use gnulib module posix_spawn_file_actions_addfchdir for portability");
969# endif
970#endif
971
972
973#endif /* _@GUARD_PREFIX@_SPAWN_H */
974#endif /* _@GUARD_PREFIX@_SPAWN_H */
diff --git a/lib/spawn_faction_addchdir.c b/lib/spawn_faction_addchdir.c
new file mode 100644
index 00000000000..8fb6cb0f7d2
--- /dev/null
+++ b/lib/spawn_faction_addchdir.c
@@ -0,0 +1,70 @@
1/* Copyright (C) 2018-2020 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 3 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <https://www.gnu.org/licenses/>. */
15
16#include <config.h>
17
18/* Specification. */
19#include <spawn.h>
20
21#include <errno.h>
22#include <stdlib.h>
23#include <string.h>
24
25#if REPLACE_POSIX_SPAWN
26# include "spawn_int.h"
27#endif
28
29/* Add an action to FILE-ACTIONS which tells the implementation to call
30 'chdir' to the given directory during the 'spawn' call. */
31int
32posix_spawn_file_actions_addchdir (posix_spawn_file_actions_t *file_actions,
33 const char *path)
34#undef posix_spawn_file_actions_addchdir
35{
36#if !REPLACE_POSIX_SPAWN
37 return posix_spawn_file_actions_addchdir_np (file_actions, path);
38#else
39 {
40 /* Copy PATH, because the caller may free it before calling posix_spawn()
41 or posix_spawnp(). */
42 char *path_copy = strdup (path);
43 if (path_copy == NULL)
44 return ENOMEM;
45
46 /* Allocate more memory if needed. */
47 if (file_actions->_used == file_actions->_allocated
48 && __posix_spawn_file_actions_realloc (file_actions) != 0)
49 {
50 /* This can only mean we ran out of memory. */
51 free (path_copy);
52 return ENOMEM;
53 }
54
55 {
56 struct __spawn_action *rec;
57
58 /* Add the new value. */
59 rec = &file_actions->_actions[file_actions->_used];
60 rec->tag = spawn_do_chdir;
61 rec->action.chdir_action.path = path_copy;
62
63 /* Account for the new entry. */
64 ++file_actions->_used;
65
66 return 0;
67 }
68 }
69#endif
70}
diff --git a/lib/spawn_faction_adddup2.c b/lib/spawn_faction_adddup2.c
new file mode 100644
index 00000000000..c00b0b49668
--- /dev/null
+++ b/lib/spawn_faction_adddup2.c
@@ -0,0 +1,70 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include <errno.h>
23#include <unistd.h>
24
25#if !_LIBC
26# define __sysconf(open_max) getdtablesize ()
27#endif
28
29#if REPLACE_POSIX_SPAWN
30# include "spawn_int.h"
31#endif
32
33/* Add an action to FILE-ACTIONS which tells the implementation to call
34 'dup2' for the given file descriptors during the 'spawn' call. */
35int
36posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *file_actions,
37 int fd, int newfd)
38#undef posix_spawn_file_actions_adddup2
39{
40 int maxfd = __sysconf (_SC_OPEN_MAX);
41
42 /* Test for the validity of the file descriptor. */
43 if (fd < 0 || newfd < 0 || fd >= maxfd || newfd >= maxfd)
44 return EBADF;
45
46#if !REPLACE_POSIX_SPAWN
47 return posix_spawn_file_actions_adddup2 (file_actions, fd, newfd);
48#else
49 /* Allocate more memory if needed. */
50 if (file_actions->_used == file_actions->_allocated
51 && __posix_spawn_file_actions_realloc (file_actions) != 0)
52 /* This can only mean we ran out of memory. */
53 return ENOMEM;
54
55 {
56 struct __spawn_action *rec;
57
58 /* Add the new value. */
59 rec = &file_actions->_actions[file_actions->_used];
60 rec->tag = spawn_do_dup2;
61 rec->action.dup2_action.fd = fd;
62 rec->action.dup2_action.newfd = newfd;
63
64 /* Account for the new entry. */
65 ++file_actions->_used;
66
67 return 0;
68 }
69#endif
70}
diff --git a/lib/spawn_faction_destroy.c b/lib/spawn_faction_destroy.c
new file mode 100644
index 00000000000..e9985f4a0d4
--- /dev/null
+++ b/lib/spawn_faction_destroy.c
@@ -0,0 +1,61 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include <stdlib.h>
23
24#if REPLACE_POSIX_SPAWN
25# include "spawn_int.h"
26#endif
27
28/* Initialize data structure for file attribute for 'spawn' call. */
29int
30posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *file_actions)
31#undef posix_spawn_file_actions_destroy
32{
33#if !REPLACE_POSIX_SPAWN
34 return posix_spawn_file_actions_destroy (file_actions);
35#else
36 int i;
37
38 /* Free the paths in the open actions. */
39 for (i = 0; i < file_actions->_used; ++i)
40 {
41 struct __spawn_action *sa = &file_actions->_actions[i];
42 switch (sa->tag)
43 {
44 case spawn_do_open:
45 free (sa->action.open_action.path);
46 break;
47 case spawn_do_chdir:
48 free (sa->action.chdir_action.path);
49 break;
50 default:
51 /* No cleanup required. */
52 break;
53 }
54 }
55
56 /* Free the array of actions. */
57 free (file_actions->_actions);
58
59 return 0;
60#endif
61}
diff --git a/lib/spawn_faction_init.c b/lib/spawn_faction_init.c
new file mode 100644
index 00000000000..135605fb8c6
--- /dev/null
+++ b/lib/spawn_faction_init.c
@@ -0,0 +1,56 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include <errno.h>
23#include <stdlib.h>
24#include <string.h>
25
26#include "spawn_int.h"
27
28
29/* Function used to increase the size of the allocated array. This
30 function is called from the 'add'-functions. */
31int
32__posix_spawn_file_actions_realloc (posix_spawn_file_actions_t *file_actions)
33{
34 int newalloc = file_actions->_allocated + 8;
35 void *newmem = realloc (file_actions->_actions,
36 newalloc * sizeof (struct __spawn_action));
37
38 if (newmem == NULL)
39 /* Not enough memory. */
40 return ENOMEM;
41
42 file_actions->_actions = (struct __spawn_action *) newmem;
43 file_actions->_allocated = newalloc;
44
45 return 0;
46}
47
48
49/* Initialize data structure for file attribute for 'spawn' call. */
50int
51posix_spawn_file_actions_init (posix_spawn_file_actions_t *file_actions)
52{
53 /* Simply clear all the elements. */
54 memset (file_actions, '\0', sizeof (*file_actions));
55 return 0;
56}
diff --git a/lib/spawn_int.h b/lib/spawn_int.h
new file mode 100644
index 00000000000..60a94ddd55a
--- /dev/null
+++ b/lib/spawn_int.h
@@ -0,0 +1,72 @@
1/* Copyright (C) 2000, 2008-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <sys/types.h>
18
19/* Data structure to contain the action information. */
20struct __spawn_action
21{
22 enum
23 {
24 spawn_do_close,
25 spawn_do_dup2,
26 spawn_do_open,
27 spawn_do_chdir,
28 spawn_do_fchdir
29 } tag;
30
31 union
32 {
33 struct
34 {
35 int fd;
36 } close_action;
37 struct
38 {
39 int fd;
40 int newfd;
41 } dup2_action;
42 struct
43 {
44 int fd;
45 char *path;
46 int oflag;
47 mode_t mode;
48 } open_action;
49 struct
50 {
51 char *path;
52 } chdir_action;
53 struct
54 {
55 int fd;
56 } fchdir_action;
57 } action;
58};
59
60#if !_LIBC
61# define __posix_spawn_file_actions_realloc gl_posix_spawn_file_actions_realloc
62#endif
63extern int __posix_spawn_file_actions_realloc (posix_spawn_file_actions_t *
64 file_actions);
65
66#if !_LIBC
67# define __spawni gl_posix_spawn_internal
68#endif
69extern int __spawni (pid_t *pid, const char *path,
70 const posix_spawn_file_actions_t *file_actions,
71 const posix_spawnattr_t *attrp, const char *const argv[],
72 const char *const envp[], int use_path);
diff --git a/lib/spawnattr_destroy.c b/lib/spawnattr_destroy.c
new file mode 100644
index 00000000000..22a7d5a61a2
--- /dev/null
+++ b/lib/spawnattr_destroy.c
@@ -0,0 +1,28 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22/* Initialize data structure for file attribute for 'spawn' call. */
23int
24posix_spawnattr_destroy (posix_spawnattr_t *attr)
25{
26 /* Nothing to do in the moment. */
27 return 0;
28}
diff --git a/lib/spawnattr_init.c b/lib/spawnattr_init.c
new file mode 100644
index 00000000000..99674488f81
--- /dev/null
+++ b/lib/spawnattr_init.c
@@ -0,0 +1,33 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include <string.h>
23
24/* Initialize data structure for file attribute for 'spawn' call. */
25int
26posix_spawnattr_init (posix_spawnattr_t *attr)
27{
28 /* All elements have to be initialized to the default values which
29 is generally zero. */
30 memset (attr, '\0', sizeof (*attr));
31
32 return 0;
33}
diff --git a/lib/spawnattr_setdefault.c b/lib/spawnattr_setdefault.c
new file mode 100644
index 00000000000..01c29e94847
--- /dev/null
+++ b/lib/spawnattr_setdefault.c
@@ -0,0 +1,33 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include <string.h>
23
24/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
25int
26posix_spawnattr_setsigdefault (posix_spawnattr_t *attr,
27 const sigset_t *sigdefault)
28{
29 /* Copy the sigset_t data to the user buffer. */
30 memcpy (&attr->_sd, sigdefault, sizeof (sigset_t));
31
32 return 0;
33}
diff --git a/lib/spawnattr_setflags.c b/lib/spawnattr_setflags.c
new file mode 100644
index 00000000000..084d5bcea4c
--- /dev/null
+++ b/lib/spawnattr_setflags.c
@@ -0,0 +1,45 @@
1/* Copyright (C) 2000, 2004, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include <errno.h>
23#include <string.h>
24
25#define ALL_FLAGS (POSIX_SPAWN_RESETIDS \
26 | POSIX_SPAWN_SETPGROUP \
27 | POSIX_SPAWN_SETSIGDEF \
28 | POSIX_SPAWN_SETSIGMASK \
29 | POSIX_SPAWN_SETSCHEDPARAM \
30 | POSIX_SPAWN_SETSCHEDULER \
31 | POSIX_SPAWN_USEVFORK)
32
33/* Store flags in the attribute structure. */
34int
35posix_spawnattr_setflags (posix_spawnattr_t *attr, short int flags)
36{
37 /* Check no invalid bits are set. */
38 if (flags & ~ALL_FLAGS)
39 return EINVAL;
40
41 /* Store the flag word. */
42 attr->_flags = flags;
43
44 return 0;
45}
diff --git a/lib/spawnattr_setpgroup.c b/lib/spawnattr_setpgroup.c
new file mode 100644
index 00000000000..479457ad23e
--- /dev/null
+++ b/lib/spawnattr_setpgroup.c
@@ -0,0 +1,32 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include <string.h>
23
24/* Store process group ID in the attribute structure. */
25int
26posix_spawnattr_setpgroup (posix_spawnattr_t *attr, pid_t pgroup)
27{
28 /* Store the process group ID. */
29 attr->_pgrp = pgroup;
30
31 return 0;
32}
diff --git a/lib/spawnattr_setsigmask.c b/lib/spawnattr_setsigmask.c
new file mode 100644
index 00000000000..9b6f9ece38e
--- /dev/null
+++ b/lib/spawnattr_setsigmask.c
@@ -0,0 +1,33 @@
1/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <spawn.h>
21
22#include <string.h>
23
24/* Set signal mask for the new process in ATTR to SIGMASK. */
25int
26posix_spawnattr_setsigmask (posix_spawnattr_t *attr,
27 const sigset_t *sigmask)
28{
29 /* Copy the sigset_t data to the user buffer. */
30 memcpy (&attr->_ss, sigmask, sizeof (sigset_t));
31
32 return 0;
33}
diff --git a/lib/spawni.c b/lib/spawni.c
new file mode 100644
index 00000000000..182d13ff24c
--- /dev/null
+++ b/lib/spawni.c
@@ -0,0 +1,349 @@
1/* Guts of POSIX spawn interface. Generic POSIX.1 version.
2 Copyright (C) 2000-2006, 2008-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <spawn.h>
22#include "spawn_int.h"
23
24#include <alloca.h>
25#include <errno.h>
26
27#include <fcntl.h>
28#ifndef O_LARGEFILE
29# define O_LARGEFILE 0
30#endif
31
32#if _LIBC || HAVE_PATHS_H
33# include <paths.h>
34#else
35# define _PATH_BSHELL BOURNE_SHELL
36#endif
37
38#include <signal.h>
39#include <stdlib.h>
40#include <string.h>
41#include <unistd.h>
42
43#if _LIBC
44# include <not-cancel.h>
45#else
46# define close_not_cancel close
47# define open_not_cancel open
48#endif
49
50#if _LIBC
51# include <local-setxid.h>
52#else
53# if !HAVE_SETEUID
54# define seteuid(id) setresuid (-1, id, -1)
55# endif
56# if !HAVE_SETEGID
57# define setegid(id) setresgid (-1, id, -1)
58# endif
59# define local_seteuid(id) seteuid (id)
60# define local_setegid(id) setegid (id)
61#endif
62
63#if _LIBC
64# define alloca __alloca
65# define execve __execve
66# define dup2 __dup2
67# define fork __fork
68# define getgid __getgid
69# define getuid __getuid
70# define sched_setparam __sched_setparam
71# define sched_setscheduler __sched_setscheduler
72# define setpgid __setpgid
73# define sigaction __sigaction
74# define sigismember __sigismember
75# define sigprocmask __sigprocmask
76# define strchrnul __strchrnul
77# define vfork __vfork
78#endif
79
80
81/* The Unix standard contains a long explanation of the way to signal
82 an error after the fork() was successful. Since no new wait status
83 was wanted there is no way to signal an error using one of the
84 available methods. The committee chose to signal an error by a
85 normal program exit with the exit code 127. */
86#define SPAWN_ERROR 127
87
88
89#if defined _WIN32 && ! defined __CYGWIN__
90
91/* Native Windows API. */
92int
93__spawni (pid_t *pid, const char *file,
94 const posix_spawn_file_actions_t *file_actions,
95 const posix_spawnattr_t *attrp, const char *const argv[],
96 const char *const envp[], int use_path)
97{
98 /* Not yet implemented. */
99 return ENOSYS;
100}
101
102#else
103
104
105/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
106 Before running the process perform the actions described in FILE-ACTIONS. */
107int
108__spawni (pid_t *pid, const char *file,
109 const posix_spawn_file_actions_t *file_actions,
110 const posix_spawnattr_t *attrp, const char *const argv[],
111 const char *const envp[], int use_path)
112{
113 pid_t new_pid;
114 char *path, *p, *name;
115 size_t len;
116 size_t pathlen;
117
118 /* Do this once. */
119 short int flags = attrp == NULL ? 0 : attrp->_flags;
120
121 /* Avoid gcc warning
122 "variable 'flags' might be clobbered by 'longjmp' or 'vfork'" */
123 (void) &flags;
124
125 /* Generate the new process. */
126#if HAVE_VFORK
127 if ((flags & POSIX_SPAWN_USEVFORK) != 0
128 /* If no major work is done, allow using vfork. Note that we
129 might perform the path searching. But this would be done by
130 a call to execvp(), too, and such a call must be OK according
131 to POSIX. */
132 || ((flags & (POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF
133 | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER
134 | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_RESETIDS)) == 0
135 && file_actions == NULL))
136 new_pid = vfork ();
137 else
138#endif
139 new_pid = fork ();
140
141 if (new_pid != 0)
142 {
143 if (new_pid < 0)
144 return errno;
145
146 /* The call was successful. Store the PID if necessary. */
147 if (pid != NULL)
148 *pid = new_pid;
149
150 return 0;
151 }
152
153 /* Set signal mask. */
154 if ((flags & POSIX_SPAWN_SETSIGMASK) != 0
155 && sigprocmask (SIG_SETMASK, &attrp->_ss, NULL) != 0)
156 _exit (SPAWN_ERROR);
157
158 /* Set signal default action. */
159 if ((flags & POSIX_SPAWN_SETSIGDEF) != 0)
160 {
161 /* We have to iterate over all signals. This could possibly be
162 done better but it requires system specific solutions since
163 the sigset_t data type can be very different on different
164 architectures. */
165 int sig;
166 struct sigaction sa;
167
168 memset (&sa, '\0', sizeof (sa));
169 sa.sa_handler = SIG_DFL;
170
171 for (sig = 1; sig <= NSIG; ++sig)
172 if (sigismember (&attrp->_sd, sig) != 0
173 && sigaction (sig, &sa, NULL) != 0)
174 _exit (SPAWN_ERROR);
175
176 }
177
178#if (_LIBC ? defined _POSIX_PRIORITY_SCHEDULING : HAVE_SCHED_SETPARAM && HAVE_SCHED_SETSCHEDULER)
179 /* Set the scheduling algorithm and parameters. */
180 if ((flags & (POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER))
181 == POSIX_SPAWN_SETSCHEDPARAM)
182 {
183 if (sched_setparam (0, &attrp->_sp) == -1)
184 _exit (SPAWN_ERROR);
185 }
186 else if ((flags & POSIX_SPAWN_SETSCHEDULER) != 0)
187 {
188 if (sched_setscheduler (0, attrp->_policy,
189 (flags & POSIX_SPAWN_SETSCHEDPARAM) != 0
190 ? &attrp->_sp : NULL) == -1)
191 _exit (SPAWN_ERROR);
192 }
193#endif
194
195 /* Set the process group ID. */
196 if ((flags & POSIX_SPAWN_SETPGROUP) != 0
197 && setpgid (0, attrp->_pgrp) != 0)
198 _exit (SPAWN_ERROR);
199
200 /* Set the effective user and group IDs. */
201 if ((flags & POSIX_SPAWN_RESETIDS) != 0
202 && (local_seteuid (getuid ()) != 0
203 || local_setegid (getgid ()) != 0))
204 _exit (SPAWN_ERROR);
205
206 /* Execute the file actions. */
207 if (file_actions != NULL)
208 {
209 int cnt;
210
211 for (cnt = 0; cnt < file_actions->_used; ++cnt)
212 {
213 struct __spawn_action *action = &file_actions->_actions[cnt];
214
215 switch (action->tag)
216 {
217 case spawn_do_close:
218 if (close_not_cancel (action->action.close_action.fd) != 0)
219 /* Signal the error. */
220 _exit (SPAWN_ERROR);
221 break;
222
223 case spawn_do_open:
224 {
225 int new_fd = open_not_cancel (action->action.open_action.path,
226 action->action.open_action.oflag
227 | O_LARGEFILE,
228 action->action.open_action.mode);
229
230 if (new_fd == -1)
231 /* The 'open' call failed. */
232 _exit (SPAWN_ERROR);
233
234 /* Make sure the desired file descriptor is used. */
235 if (new_fd != action->action.open_action.fd)
236 {
237 if (dup2 (new_fd, action->action.open_action.fd)
238 != action->action.open_action.fd)
239 /* The 'dup2' call failed. */
240 _exit (SPAWN_ERROR);
241
242 if (close_not_cancel (new_fd) != 0)
243 /* The 'close' call failed. */
244 _exit (SPAWN_ERROR);
245 }
246 }
247 break;
248
249 case spawn_do_dup2:
250 if (dup2 (action->action.dup2_action.fd,
251 action->action.dup2_action.newfd)
252 != action->action.dup2_action.newfd)
253 /* The 'dup2' call failed. */
254 _exit (SPAWN_ERROR);
255 break;
256
257 case spawn_do_chdir:
258 if (chdir (action->action.chdir_action.path) < 0)
259 /* The 'chdir' call failed. */
260 _exit (SPAWN_ERROR);
261 break;
262
263 case spawn_do_fchdir:
264 if (fchdir (action->action.fchdir_action.fd) < 0)
265 /* The 'fchdir' call failed. */
266 _exit (SPAWN_ERROR);
267 break;
268 }
269 }
270 }
271
272 if (! use_path || strchr (file, '/') != NULL)
273 {
274 /* The FILE parameter is actually a path. */
275 execve (file, (char * const *) argv, (char * const *) envp);
276
277 /* Oh, oh. 'execve' returns. This is bad. */
278 _exit (SPAWN_ERROR);
279 }
280
281 /* We have to search for FILE on the path. */
282 path = getenv ("PATH");
283 if (path == NULL)
284 {
285#if HAVE_CONFSTR
286 /* There is no 'PATH' in the environment.
287 The default search path is the current directory
288 followed by the path 'confstr' returns for '_CS_PATH'. */
289 len = confstr (_CS_PATH, (char *) NULL, 0);
290 path = (char *) alloca (1 + len);
291 path[0] = ':';
292 (void) confstr (_CS_PATH, path + 1, len);
293#else
294 /* Pretend that the PATH contains only the current directory. */
295 path = "";
296#endif
297 }
298
299 len = strlen (file) + 1;
300 pathlen = strlen (path);
301 name = alloca (pathlen + len + 1);
302 /* Copy the file name at the top. */
303 name = (char *) memcpy (name + pathlen + 1, file, len);
304 /* And add the slash. */
305 *--name = '/';
306
307 p = path;
308 do
309 {
310 char *startp;
311
312 path = p;
313 p = strchrnul (path, ':');
314
315 if (p == path)
316 /* Two adjacent colons, or a colon at the beginning or the end
317 of 'PATH' means to search the current directory. */
318 startp = name + 1;
319 else
320 startp = (char *) memcpy (name - (p - path), path, p - path);
321
322 /* Try to execute this name. If it works, execv will not return. */
323 execve (startp, (char * const *) argv, (char * const *) envp);
324
325 switch (errno)
326 {
327 case EACCES:
328 case ENOENT:
329 case ESTALE:
330 case ENOTDIR:
331 /* Those errors indicate the file is missing or not executable
332 by us, in which case we want to just try the next path
333 directory. */
334 break;
335
336 default:
337 /* Some other error means we found an executable file, but
338 something went wrong executing it; return the error to our
339 caller. */
340 _exit (SPAWN_ERROR);
341 }
342 }
343 while (*p++ != '\0');
344
345 /* Return with an error. */
346 _exit (SPAWN_ERROR);
347}
348
349#endif
diff --git a/lib/strchrnul.c b/lib/strchrnul.c
new file mode 100644
index 00000000000..858d66fab18
--- /dev/null
+++ b/lib/strchrnul.c
@@ -0,0 +1,142 @@
1/* Searching in a string.
2 Copyright (C) 2003, 2007-2020 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <string.h>
21
22/* Find the first occurrence of C in S or the final NUL byte. */
23char *
24strchrnul (const char *s, int c_in)
25{
26 /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
27 long instead of a 64-bit uintmax_t tends to give better
28 performance. On 64-bit hardware, unsigned long is generally 64
29 bits already. Change this typedef to experiment with
30 performance. */
31 typedef unsigned long int longword;
32
33 const unsigned char *char_ptr;
34 const longword *longword_ptr;
35 longword repeated_one;
36 longword repeated_c;
37 unsigned char c;
38
39 c = (unsigned char) c_in;
40 if (!c)
41 return rawmemchr (s, 0);
42
43 /* Handle the first few bytes by reading one byte at a time.
44 Do this until CHAR_PTR is aligned on a longword boundary. */
45 for (char_ptr = (const unsigned char *) s;
46 (size_t) char_ptr % sizeof (longword) != 0;
47 ++char_ptr)
48 if (!*char_ptr || *char_ptr == c)
49 return (char *) char_ptr;
50
51 longword_ptr = (const longword *) char_ptr;
52
53 /* All these elucidatory comments refer to 4-byte longwords,
54 but the theory applies equally well to any size longwords. */
55
56 /* Compute auxiliary longword values:
57 repeated_one is a value which has a 1 in every byte.
58 repeated_c has c in every byte. */
59 repeated_one = 0x01010101;
60 repeated_c = c | (c << 8);
61 repeated_c |= repeated_c << 16;
62 if (0xffffffffU < (longword) -1)
63 {
64 repeated_one |= repeated_one << 31 << 1;
65 repeated_c |= repeated_c << 31 << 1;
66 if (8 < sizeof (longword))
67 {
68 size_t i;
69
70 for (i = 64; i < sizeof (longword) * 8; i *= 2)
71 {
72 repeated_one |= repeated_one << i;
73 repeated_c |= repeated_c << i;
74 }
75 }
76 }
77
78 /* Instead of the traditional loop which tests each byte, we will
79 test a longword at a time. The tricky part is testing if *any of
80 the four* bytes in the longword in question are equal to NUL or
81 c. We first use an xor with repeated_c. This reduces the task
82 to testing whether *any of the four* bytes in longword1 or
83 longword2 is zero.
84
85 Let's consider longword1. We compute tmp =
86 ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
87 That is, we perform the following operations:
88 1. Subtract repeated_one.
89 2. & ~longword1.
90 3. & a mask consisting of 0x80 in every byte.
91 Consider what happens in each byte:
92 - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
93 and step 3 transforms it into 0x80. A carry can also be propagated
94 to more significant bytes.
95 - If a byte of longword1 is nonzero, let its lowest 1 bit be at
96 position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
97 the byte ends in a single bit of value 0 and k bits of value 1.
98 After step 2, the result is just k bits of value 1: 2^k - 1. After
99 step 3, the result is 0. And no carry is produced.
100 So, if longword1 has only non-zero bytes, tmp is zero.
101 Whereas if longword1 has a zero byte, call j the position of the least
102 significant zero byte. Then the result has a zero at positions 0, ...,
103 j-1 and a 0x80 at position j. We cannot predict the result at the more
104 significant bytes (positions j+1..3), but it does not matter since we
105 already have a non-zero bit at position 8*j+7.
106
107 The test whether any byte in longword1 or longword2 is zero is equivalent
108 to testing whether tmp1 is nonzero or tmp2 is nonzero. We can combine
109 this into a single test, whether (tmp1 | tmp2) is nonzero.
110
111 This test can read more than one byte beyond the end of a string,
112 depending on where the terminating NUL is encountered. However,
113 this is considered safe since the initialization phase ensured
114 that the read will be aligned, therefore, the read will not cross
115 page boundaries and will not cause a fault. */
116
117 while (1)
118 {
119 longword longword1 = *longword_ptr ^ repeated_c;
120 longword longword2 = *longword_ptr;
121
122 if (((((longword1 - repeated_one) & ~longword1)
123 | ((longword2 - repeated_one) & ~longword2))
124 & (repeated_one << 7)) != 0)
125 break;
126 longword_ptr++;
127 }
128
129 char_ptr = (const unsigned char *) longword_ptr;
130
131 /* At this point, we know that one of the sizeof (longword) bytes
132 starting at char_ptr is == 0 or == c. On little-endian machines,
133 we could determine the first such byte without any further memory
134 accesses, just by looking at the tmp result from the last loop
135 iteration. But this does not work on big-endian machines.
136 Choose code that works in both cases. */
137
138 char_ptr = (unsigned char *) longword_ptr;
139 while (*char_ptr && (*char_ptr != c))
140 char_ptr++;
141 return (char *) char_ptr;
142}
diff --git a/lib/strchrnul.valgrind b/lib/strchrnul.valgrind
new file mode 100644
index 00000000000..a85608a7c76
--- /dev/null
+++ b/lib/strchrnul.valgrind
@@ -0,0 +1,28 @@
1# Suppress a valgrind message about use of uninitialized memory in strchrnul().
2
3# Copyright (C) 2008-2020 Free Software Foundation, Inc.
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <https://www.gnu.org/licenses/>.
17
18# This use is OK because it provides only a speedup.
19{
20 strchrnul-value4
21 Memcheck:Value4
22 fun:strchrnul
23}
24{
25 strchrnul-value8
26 Memcheck:Value8
27 fun:strchrnul
28}
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 0971636c33d..e2a44efe621 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -139,6 +139,18 @@ AC_DEFUN([gl_EARLY],
139 # Code from module openat-h: 139 # Code from module openat-h:
140 # Code from module pathmax: 140 # Code from module pathmax:
141 # Code from module pipe2: 141 # Code from module pipe2:
142 # Code from module posix_spawn:
143 # Code from module posix_spawn-internal:
144 # Code from module posix_spawn_file_actions_addchdir:
145 # Code from module posix_spawn_file_actions_adddup2:
146 # Code from module posix_spawn_file_actions_destroy:
147 # Code from module posix_spawn_file_actions_init:
148 # Code from module posix_spawnattr_destroy:
149 # Code from module posix_spawnattr_init:
150 # Code from module posix_spawnattr_setflags:
151 # Code from module posix_spawnattr_setpgroup:
152 # Code from module posix_spawnattr_setsigdefault:
153 # Code from module posix_spawnattr_setsigmask:
142 # Code from module pselect: 154 # Code from module pselect:
143 # Code from module pthread_sigmask: 155 # Code from module pthread_sigmask:
144 # Code from module qcopy-acl: 156 # Code from module qcopy-acl:
@@ -147,7 +159,9 @@ AC_DEFUN([gl_EARLY],
147 # Code from module readlinkat: 159 # Code from module readlinkat:
148 # Code from module regex: 160 # Code from module regex:
149 # Code from module root-uid: 161 # Code from module root-uid:
162 # Code from module sched:
150 # Code from module scratch_buffer: 163 # Code from module scratch_buffer:
164 # Code from module sh-filename:
151 # Code from module sig2str: 165 # Code from module sig2str:
152 # Code from module sigdescr_np: 166 # Code from module sigdescr_np:
153 # Code from module signal-h: 167 # Code from module signal-h:
@@ -156,6 +170,7 @@ AC_DEFUN([gl_EARLY],
156 # Code from module snippet/c++defs: 170 # Code from module snippet/c++defs:
157 # Code from module snippet/warn-on-use: 171 # Code from module snippet/warn-on-use:
158 # Code from module socklen: 172 # Code from module socklen:
173 # Code from module spawn:
159 # Code from module ssize_t: 174 # Code from module ssize_t:
160 # Code from module stat-time: 175 # Code from module stat-time:
161 # Code from module std-gnu11: 176 # Code from module std-gnu11:
@@ -165,6 +180,7 @@ AC_DEFUN([gl_EARLY],
165 # Code from module stdio: 180 # Code from module stdio:
166 # Code from module stdlib: 181 # Code from module stdlib:
167 # Code from module stpcpy: 182 # Code from module stpcpy:
183 # Code from module strchrnul:
168 # Code from module string: 184 # Code from module string:
169 # Code from module strnlen: 185 # Code from module strnlen:
170 # Code from module strtoimax: 186 # Code from module strtoimax:
@@ -403,6 +419,61 @@ AC_DEFUN([gl_INIT],
403 gl_PATHMAX 419 gl_PATHMAX
404 gl_FUNC_PIPE2 420 gl_FUNC_PIPE2
405 gl_UNISTD_MODULE_INDICATOR([pipe2]) 421 gl_UNISTD_MODULE_INDICATOR([pipe2])
422 gl_POSIX_SPAWN
423 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
424 AC_LIBOBJ([spawn])
425 fi
426 gl_SPAWN_MODULE_INDICATOR([posix_spawn])
427 gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
428 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 1; then
429 AC_LIBOBJ([spawn_faction_addchdir])
430 fi
431 gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_addchdir])
432 gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2
433 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1; then
434 AC_LIBOBJ([spawn_faction_adddup2])
435 fi
436 gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_adddup2])
437 gl_POSIX_SPAWN
438 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
439 AC_LIBOBJ([spawn_faction_destroy])
440 fi
441 gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_destroy])
442 gl_POSIX_SPAWN
443 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
444 AC_LIBOBJ([spawn_faction_init])
445 fi
446 gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_init])
447 gl_POSIX_SPAWN
448 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
449 AC_LIBOBJ([spawnattr_destroy])
450 fi
451 gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_destroy])
452 gl_POSIX_SPAWN
453 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
454 AC_LIBOBJ([spawnattr_init])
455 fi
456 gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_init])
457 gl_POSIX_SPAWN
458 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
459 AC_LIBOBJ([spawnattr_setflags])
460 fi
461 gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setflags])
462 gl_POSIX_SPAWN
463 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
464 AC_LIBOBJ([spawnattr_setpgroup])
465 fi
466 gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setpgroup])
467 gl_POSIX_SPAWN
468 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
469 AC_LIBOBJ([spawnattr_setdefault])
470 fi
471 gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setsigdefault])
472 gl_POSIX_SPAWN
473 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
474 AC_LIBOBJ([spawnattr_setsigmask])
475 fi
476 gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setsigmask])
406 gl_FUNC_PSELECT 477 gl_FUNC_PSELECT
407 if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then 478 if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then
408 AC_LIBOBJ([pselect]) 479 AC_LIBOBJ([pselect])
@@ -430,6 +501,7 @@ AC_DEFUN([gl_INIT],
430 AC_LIBOBJ([regex]) 501 AC_LIBOBJ([regex])
431 gl_PREREQ_REGEX 502 gl_PREREQ_REGEX
432 fi 503 fi
504 gl_SCHED_H
433 gl_FUNC_SIG2STR 505 gl_FUNC_SIG2STR
434 if test $ac_cv_func_sig2str = no; then 506 if test $ac_cv_func_sig2str = no; then
435 AC_LIBOBJ([sig2str]) 507 AC_LIBOBJ([sig2str])
@@ -442,6 +514,7 @@ AC_DEFUN([gl_INIT],
442 gl_STRING_MODULE_INDICATOR([sigdescr_np]) 514 gl_STRING_MODULE_INDICATOR([sigdescr_np])
443 gl_SIGNAL_H 515 gl_SIGNAL_H
444 gl_TYPE_SOCKLEN_T 516 gl_TYPE_SOCKLEN_T
517 gl_SPAWN_H
445 gt_TYPE_SSIZE_T 518 gt_TYPE_SSIZE_T
446 gl_STAT_TIME 519 gl_STAT_TIME
447 gl_STAT_BIRTHTIME 520 gl_STAT_BIRTHTIME
@@ -528,9 +601,12 @@ AC_DEFUN([gl_INIT],
528 gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false 601 gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false
529 gl_gnulib_enabled_open=false 602 gl_gnulib_enabled_open=false
530 gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false 603 gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false
604 gl_gnulib_enabled_332607f759618fb73dfc3076748afea7=false
531 gl_gnulib_enabled_rawmemchr=false 605 gl_gnulib_enabled_rawmemchr=false
532 gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false 606 gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false
533 gl_gnulib_enabled_scratch_buffer=false 607 gl_gnulib_enabled_scratch_buffer=false
608 gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70=false
609 gl_gnulib_enabled_strchrnul=false
534 gl_gnulib_enabled_strtoll=false 610 gl_gnulib_enabled_strtoll=false
535 gl_gnulib_enabled_utimens=false 611 gl_gnulib_enabled_utimens=false
536 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false 612 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false
@@ -685,6 +761,20 @@ AC_DEFUN([gl_INIT],
685 gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=true 761 gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=true
686 fi 762 fi
687 } 763 }
764 func_gl_gnulib_m4code_332607f759618fb73dfc3076748afea7 ()
765 {
766 if ! $gl_gnulib_enabled_332607f759618fb73dfc3076748afea7; then
767 gl_POSIX_SPAWN
768 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
769 AC_LIBOBJ([spawni])
770 gl_PREREQ_POSIX_SPAWN_INTERNAL
771 fi
772 gl_gnulib_enabled_332607f759618fb73dfc3076748afea7=true
773 func_gl_gnulib_m4code_open
774 func_gl_gnulib_m4code_cdeb0f2aaf9d280baa6526bfa1b07f70
775 func_gl_gnulib_m4code_strchrnul
776 fi
777 }
688 func_gl_gnulib_m4code_rawmemchr () 778 func_gl_gnulib_m4code_rawmemchr ()
689 { 779 {
690 if ! $gl_gnulib_enabled_rawmemchr; then 780 if ! $gl_gnulib_enabled_rawmemchr; then
@@ -709,6 +799,28 @@ AC_DEFUN([gl_INIT],
709 gl_gnulib_enabled_scratch_buffer=true 799 gl_gnulib_enabled_scratch_buffer=true
710 fi 800 fi
711 } 801 }
802 func_gl_gnulib_m4code_cdeb0f2aaf9d280baa6526bfa1b07f70 ()
803 {
804 if ! $gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70; then
805 gl_SH_FILENAME
806 gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70=true
807 fi
808 }
809 func_gl_gnulib_m4code_strchrnul ()
810 {
811 if ! $gl_gnulib_enabled_strchrnul; then
812 gl_FUNC_STRCHRNUL
813 if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then
814 AC_LIBOBJ([strchrnul])
815 gl_PREREQ_STRCHRNUL
816 fi
817 gl_STRING_MODULE_INDICATOR([strchrnul])
818 gl_gnulib_enabled_strchrnul=true
819 if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then
820 func_gl_gnulib_m4code_rawmemchr
821 fi
822 fi
823 }
712 func_gl_gnulib_m4code_strtoll () 824 func_gl_gnulib_m4code_strtoll ()
713 { 825 {
714 if ! $gl_gnulib_enabled_strtoll; then 826 if ! $gl_gnulib_enabled_strtoll; then
@@ -791,6 +903,12 @@ AC_DEFUN([gl_INIT],
791 if case $host_os in mingw*) false;; *) test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1;; esac; then 903 if case $host_os in mingw*) false;; *) test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1;; esac; then
792 func_gl_gnulib_m4code_open 904 func_gl_gnulib_m4code_open
793 fi 905 fi
906 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then
907 func_gl_gnulib_m4code_332607f759618fb73dfc3076748afea7
908 fi
909 if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1; then
910 func_gl_gnulib_m4code_getdtablesize
911 fi
794 if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then 912 if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then
795 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b 913 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
796 fi 914 fi
@@ -830,9 +948,12 @@ AC_DEFUN([gl_INIT],
830 AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) 948 AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31])
831 AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open]) 949 AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open])
832 AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) 950 AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7])
951 AM_CONDITIONAL([gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7], [$gl_gnulib_enabled_332607f759618fb73dfc3076748afea7])
833 AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr]) 952 AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr])
834 AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) 953 AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c])
835 AM_CONDITIONAL([gl_GNULIB_ENABLED_scratch_buffer], [$gl_gnulib_enabled_scratch_buffer]) 954 AM_CONDITIONAL([gl_GNULIB_ENABLED_scratch_buffer], [$gl_gnulib_enabled_scratch_buffer])
955 AM_CONDITIONAL([gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70], [$gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70])
956 AM_CONDITIONAL([gl_GNULIB_ENABLED_strchrnul], [$gl_gnulib_enabled_strchrnul])
836 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) 957 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll])
837 AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens]) 958 AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens])
838 AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) 959 AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec])
@@ -1113,6 +1234,7 @@ AC_DEFUN([gl_FILE_LIST], [
1113 lib/regex_internal.h 1234 lib/regex_internal.h
1114 lib/regexec.c 1235 lib/regexec.c
1115 lib/root-uid.h 1236 lib/root-uid.h
1237 lib/sched.in.h
1116 lib/scratch_buffer.h 1238 lib/scratch_buffer.h
1117 lib/set-permissions.c 1239 lib/set-permissions.c
1118 lib/sha1.c 1240 lib/sha1.c
@@ -1125,6 +1247,20 @@ AC_DEFUN([gl_FILE_LIST], [
1125 lib/sig2str.h 1247 lib/sig2str.h
1126 lib/sigdescr_np.c 1248 lib/sigdescr_np.c
1127 lib/signal.in.h 1249 lib/signal.in.h
1250 lib/spawn.c
1251 lib/spawn.in.h
1252 lib/spawn_faction_addchdir.c
1253 lib/spawn_faction_adddup2.c
1254 lib/spawn_faction_destroy.c
1255 lib/spawn_faction_init.c
1256 lib/spawn_int.h
1257 lib/spawnattr_destroy.c
1258 lib/spawnattr_init.c
1259 lib/spawnattr_setdefault.c
1260 lib/spawnattr_setflags.c
1261 lib/spawnattr_setpgroup.c
1262 lib/spawnattr_setsigmask.c
1263 lib/spawni.c
1128 lib/stat-time.c 1264 lib/stat-time.c
1129 lib/stat-time.h 1265 lib/stat-time.h
1130 lib/stdalign.in.h 1266 lib/stdalign.in.h
@@ -1135,6 +1271,8 @@ AC_DEFUN([gl_FILE_LIST], [
1135 lib/stdlib.in.h 1271 lib/stdlib.in.h
1136 lib/stpcpy.c 1272 lib/stpcpy.c
1137 lib/str-two-way.h 1273 lib/str-two-way.h
1274 lib/strchrnul.c
1275 lib/strchrnul.valgrind
1138 lib/strftime.h 1276 lib/strftime.h
1139 lib/string.in.h 1277 lib/string.in.h
1140 lib/strnlen.c 1278 lib/strnlen.c
@@ -1248,12 +1386,16 @@ AC_DEFUN([gl_FILE_LIST], [
1248 m4/pathmax.m4 1386 m4/pathmax.m4
1249 m4/pid_t.m4 1387 m4/pid_t.m4
1250 m4/pipe2.m4 1388 m4/pipe2.m4
1389 m4/posix_spawn.m4
1390 m4/posix_spawn_faction_addchdir.m4
1251 m4/pselect.m4 1391 m4/pselect.m4
1252 m4/pthread_sigmask.m4 1392 m4/pthread_sigmask.m4
1253 m4/rawmemchr.m4 1393 m4/rawmemchr.m4
1254 m4/readlink.m4 1394 m4/readlink.m4
1255 m4/readlinkat.m4 1395 m4/readlinkat.m4
1256 m4/regex.m4 1396 m4/regex.m4
1397 m4/sched_h.m4
1398 m4/sh-filename.m4
1257 m4/sha1.m4 1399 m4/sha1.m4
1258 m4/sha256.m4 1400 m4/sha256.m4
1259 m4/sha512.m4 1401 m4/sha512.m4
@@ -1261,6 +1403,7 @@ AC_DEFUN([gl_FILE_LIST], [
1261 m4/sigdescr_np.m4 1403 m4/sigdescr_np.m4
1262 m4/signal_h.m4 1404 m4/signal_h.m4
1263 m4/socklen.m4 1405 m4/socklen.m4
1406 m4/spawn_h.m4
1264 m4/ssize_t.m4 1407 m4/ssize_t.m4
1265 m4/stat-time.m4 1408 m4/stat-time.m4
1266 m4/std-gnu11.m4 1409 m4/std-gnu11.m4
@@ -1270,6 +1413,7 @@ AC_DEFUN([gl_FILE_LIST], [
1270 m4/stdio_h.m4 1413 m4/stdio_h.m4
1271 m4/stdlib_h.m4 1414 m4/stdlib_h.m4
1272 m4/stpcpy.m4 1415 m4/stpcpy.m4
1416 m4/strchrnul.m4
1273 m4/string_h.m4 1417 m4/string_h.m4
1274 m4/strnlen.m4 1418 m4/strnlen.m4
1275 m4/strtoimax.m4 1419 m4/strtoimax.m4
diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4
new file mode 100644
index 00000000000..59e56fcb5f2
--- /dev/null
+++ b/m4/posix_spawn.m4
@@ -0,0 +1,678 @@
1# posix_spawn.m4 serial 19
2dnl Copyright (C) 2008-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Tests whether the entire posix_spawn facility is available.
8AC_DEFUN([gl_POSIX_SPAWN],
9[
10 AC_REQUIRE([gl_POSIX_SPAWN_BODY])
11])
12
13AC_DEFUN([gl_POSIX_SPAWN_BODY],
14[
15 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
16 AC_REQUIRE([gl_HAVE_POSIX_SPAWN])
17 dnl Assume that when the main function exists, all the others,
18 dnl except posix_spawnattr_{get,set}sched*, are available as well.
19 dnl AC_CHECK_FUNCS_ONCE([posix_spawnp])
20 dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_init])
21 dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addclose])
22 dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_adddup2])
23 dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addopen])
24 dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_destroy])
25 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_init])
26 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getflags])
27 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setflags])
28 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getpgroup])
29 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setpgroup])
30 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getsigdefault])
31 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setsigdefault])
32 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getsigmask])
33 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setsigmask])
34 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_destroy])
35 if test $ac_cv_func_posix_spawn = yes; then
36 m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR],
37 [dnl Module 'posix_spawn_file_actions_addchdir' is present.
38 AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir_np])
39 if test $ac_cv_func_posix_spawn_file_actions_addchdir_np = no; then
40 dnl In order to implement the posix_spawn_file_actions_addchdir
41 dnl function, we need to replace the entire posix_spawn facility.
42 REPLACE_POSIX_SPAWN=1
43 fi
44 ])
45 m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR],
46 [dnl Module 'posix_spawn_file_actions_addfchdir' is present.
47 AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir_np])
48 if test $ac_cv_func_posix_spawn_file_actions_addfchdir_np = no; then
49 dnl In order to implement the posix_spawn_file_actions_addfchdir
50 dnl function, we need to replace the entire posix_spawn facility.
51 REPLACE_POSIX_SPAWN=1
52 fi
53 ])
54 if test $REPLACE_POSIX_SPAWN = 0; then
55 gl_POSIX_SPAWN_WORKS
56 case "$gl_cv_func_posix_spawn_works" in
57 *yes) ;;
58 *) REPLACE_POSIX_SPAWN=1 ;;
59 esac
60 fi
61 if test $REPLACE_POSIX_SPAWN = 0; then
62 gl_POSIX_SPAWN_SECURE
63 case "$gl_cv_func_posix_spawn_secure_exec" in
64 *yes) ;;
65 *) REPLACE_POSIX_SPAWN=1 ;;
66 esac
67 case "$gl_cv_func_posix_spawnp_secure_exec" in
68 *yes) ;;
69 *) REPLACE_POSIX_SPAWN=1 ;;
70 esac
71 fi
72 if test $REPLACE_POSIX_SPAWN = 0; then
73 dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDULER
74 dnl evaluates to nonzero.
75 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedpolicy])
76 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedpolicy])
77 AC_CACHE_CHECK([whether posix_spawnattr_setschedpolicy is supported],
78 [gl_cv_func_spawnattr_setschedpolicy],
79 [AC_EGREP_CPP([POSIX scheduling supported], [
80#include <spawn.h>
81#if POSIX_SPAWN_SETSCHEDULER
82 POSIX scheduling supported
83#endif
84],
85 [gl_cv_func_spawnattr_setschedpolicy=yes],
86 [gl_cv_func_spawnattr_setschedpolicy=no])
87 ])
88 dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDPARAM
89 dnl evaluates to nonzero.
90 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedparam])
91 dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedparam])
92 AC_CACHE_CHECK([whether posix_spawnattr_setschedparam is supported],
93 [gl_cv_func_spawnattr_setschedparam],
94 [AC_EGREP_CPP([POSIX scheduling supported], [
95#include <spawn.h>
96#if POSIX_SPAWN_SETSCHEDPARAM
97 POSIX scheduling supported
98#endif
99],
100 [gl_cv_func_spawnattr_setschedparam=yes],
101 [gl_cv_func_spawnattr_setschedparam=no])
102 ])
103 fi
104 fi
105 if test $ac_cv_func_posix_spawn != yes || test $REPLACE_POSIX_SPAWN = 1; then
106 AC_DEFINE([REPLACE_POSIX_SPAWN], [1],
107 [Define if gnulib uses its own posix_spawn and posix_spawnp functions.])
108 fi
109])
110
111dnl Test whether posix_spawn actually works.
112dnl posix_spawn on AIX 5.3..6.1 has two bugs:
113dnl 1) When it fails to execute the program, the child process exits with
114dnl exit() rather than _exit(), which causes the stdio buffers to be
115dnl flushed. Reported by Rainer Tammer.
116dnl 2) The posix_spawn_file_actions_addopen function does not support file
117dnl names that contain a '*'.
118dnl posix_spawn on AIX 5.3..6.1 has also a third bug: It does not work
119dnl when POSIX threads are used. But we don't test against this bug here.
120AC_DEFUN([gl_POSIX_SPAWN_WORKS],
121[
122 AC_REQUIRE([AC_PROG_CC])
123 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
124 AC_CACHE_CHECK([whether posix_spawn works], [gl_cv_func_posix_spawn_works],
125 [if test $cross_compiling = no; then
126 AC_LINK_IFELSE([AC_LANG_SOURCE([[
127#include <errno.h>
128#include <fcntl.h>
129#include <signal.h>
130#include <spawn.h>
131#include <stdbool.h>
132#include <stdio.h>
133#include <stdlib.h>
134#include <string.h>
135#include <unistd.h>
136#include <sys/types.h>
137#include <sys/wait.h>
138]GL_MDA_DEFINES[
139
140extern char **environ;
141
142#ifndef STDIN_FILENO
143# define STDIN_FILENO 0
144#endif
145#ifndef STDOUT_FILENO
146# define STDOUT_FILENO 1
147#endif
148#ifndef STDERR_FILENO
149# define STDERR_FILENO 2
150#endif
151
152#ifndef WTERMSIG
153# define WTERMSIG(x) ((x) & 0x7f)
154#endif
155#ifndef WIFEXITED
156# define WIFEXITED(x) (WTERMSIG (x) == 0)
157#endif
158#ifndef WEXITSTATUS
159# define WEXITSTATUS(x) (((x) >> 8) & 0xff)
160#endif
161
162#define CHILD_PROGRAM_FILENAME "/non/exist/ent"
163
164static int
165fd_safer (int fd)
166{
167 if (0 <= fd && fd <= 2)
168 {
169 int f = fd_safer (dup (fd));
170 int e = errno;
171 close (fd);
172 errno = e;
173 fd = f;
174 }
175
176 return fd;
177}
178
179int
180main ()
181{
182 char *argv[2] = { CHILD_PROGRAM_FILENAME, NULL };
183 int ofd[2];
184 sigset_t blocked_signals;
185 sigset_t fatal_signal_set;
186 posix_spawn_file_actions_t actions;
187 bool actions_allocated;
188 posix_spawnattr_t attrs;
189 bool attrs_allocated;
190 int err;
191 pid_t child;
192 int status;
193 int exitstatus;
194
195 setvbuf (stdout, NULL, _IOFBF, 0);
196 puts ("This should be seen only once.");
197 if (pipe (ofd) < 0 || (ofd[1] = fd_safer (ofd[1])) < 0)
198 {
199 perror ("cannot create pipe");
200 exit (1);
201 }
202 sigprocmask (SIG_SETMASK, NULL, &blocked_signals);
203 sigemptyset (&fatal_signal_set);
204 sigaddset (&fatal_signal_set, SIGINT);
205 sigaddset (&fatal_signal_set, SIGTERM);
206 sigaddset (&fatal_signal_set, SIGHUP);
207 sigaddset (&fatal_signal_set, SIGPIPE);
208 sigprocmask (SIG_BLOCK, &fatal_signal_set, NULL);
209 actions_allocated = false;
210 attrs_allocated = false;
211 if ((err = posix_spawn_file_actions_init (&actions)) != 0
212 || (actions_allocated = true,
213 (err = posix_spawn_file_actions_adddup2 (&actions, ofd[0], STDIN_FILENO)) != 0
214 || (err = posix_spawn_file_actions_addclose (&actions, ofd[0])) != 0
215 || (err = posix_spawn_file_actions_addclose (&actions, ofd[1])) != 0
216 || (err = posix_spawnattr_init (&attrs)) != 0
217 || (attrs_allocated = true,
218 (err = posix_spawnattr_setsigmask (&attrs, &blocked_signals)) != 0
219 || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0)
220 || (err = posix_spawnp (&child, CHILD_PROGRAM_FILENAME, &actions, &attrs, argv, environ)) != 0))
221 {
222 if (actions_allocated)
223 posix_spawn_file_actions_destroy (&actions);
224 if (attrs_allocated)
225 posix_spawnattr_destroy (&attrs);
226 sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL);
227 if (err == ENOENT)
228 return 0;
229 else
230 {
231 errno = err;
232 perror ("subprocess failed");
233 exit (1);
234 }
235 }
236 posix_spawn_file_actions_destroy (&actions);
237 posix_spawnattr_destroy (&attrs);
238 sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL);
239 close (ofd[0]);
240 close (ofd[1]);
241 status = 0;
242 while (waitpid (child, &status, 0) != child)
243 ;
244 if (!WIFEXITED (status))
245 {
246 fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status);
247 exit (1);
248 }
249 exitstatus = WEXITSTATUS (status);
250 if (exitstatus != 127)
251 {
252 fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus);
253 exit (1);
254 }
255 return 0;
256}
257]])],
258 [if test -s conftest$ac_exeext \
259 && ./conftest$ac_exeext > conftest.out \
260 && echo 'This should be seen only once.' > conftest.ok \
261 && cmp conftest.out conftest.ok >/dev/null 2>&1; then
262 gl_cv_func_posix_spawn_works=yes
263 else
264 gl_cv_func_posix_spawn_works=no
265 fi],
266 [gl_cv_func_posix_spawn_works=no])
267 if test $gl_cv_func_posix_spawn_works = yes; then
268 AC_RUN_IFELSE([AC_LANG_SOURCE([[
269/* Test whether posix_spawn_file_actions_addopen supports filename arguments
270 that contain special characters such as '*'. */
271
272#include <errno.h>
273#include <fcntl.h>
274#include <signal.h>
275#include <spawn.h>
276#include <stdbool.h>
277#include <stdio.h>
278#include <string.h>
279#include <unistd.h>
280#include <sys/types.h>
281#include <sys/wait.h>
282]GL_MDA_DEFINES[
283
284extern char **environ;
285
286#ifndef STDIN_FILENO
287# define STDIN_FILENO 0
288#endif
289#ifndef STDOUT_FILENO
290# define STDOUT_FILENO 1
291#endif
292#ifndef STDERR_FILENO
293# define STDERR_FILENO 2
294#endif
295
296#ifndef WTERMSIG
297# define WTERMSIG(x) ((x) & 0x7f)
298#endif
299#ifndef WIFEXITED
300# define WIFEXITED(x) (WTERMSIG (x) == 0)
301#endif
302#ifndef WEXITSTATUS
303# define WEXITSTATUS(x) (((x) >> 8) & 0xff)
304#endif
305
306#define CHILD_PROGRAM_FILENAME "conftest"
307#define DATA_FILENAME "conftest%=*#?"
308
309static int
310parent_main (void)
311{
312 FILE *fp;
313 char *argv[3] = { CHILD_PROGRAM_FILENAME, "-child", NULL };
314 posix_spawn_file_actions_t actions;
315 bool actions_allocated;
316 int err;
317 pid_t child;
318 int status;
319 int exitstatus;
320
321 /* Create a data file with specific contents. */
322 fp = fopen (DATA_FILENAME, "wb");
323 if (fp == NULL)
324 {
325 perror ("cannot create data file");
326 return 1;
327 }
328 fwrite ("Halle Potta", 1, 11, fp);
329 if (fflush (fp) || fclose (fp))
330 {
331 perror ("cannot prepare data file");
332 return 2;
333 }
334
335 /* Avoid reading from our stdin, as it could block. */
336 freopen ("/dev/null", "rb", stdin);
337
338 /* Test whether posix_spawn_file_actions_addopen with this file name
339 actually works, but spawning a child that reads from this file. */
340 actions_allocated = false;
341 if ((err = posix_spawn_file_actions_init (&actions)) != 0
342 || (actions_allocated = true,
343 (err = posix_spawn_file_actions_addopen (&actions, STDIN_FILENO, DATA_FILENAME, O_RDONLY, 0600)) != 0
344 || (err = posix_spawn (&child, CHILD_PROGRAM_FILENAME, &actions, NULL, argv, environ)) != 0))
345 {
346 if (actions_allocated)
347 posix_spawn_file_actions_destroy (&actions);
348 errno = err;
349 perror ("subprocess failed");
350 return 3;
351 }
352 posix_spawn_file_actions_destroy (&actions);
353 status = 0;
354 while (waitpid (child, &status, 0) != child)
355 ;
356 if (!WIFEXITED (status))
357 {
358 fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status);
359 return 4;
360 }
361 exitstatus = WEXITSTATUS (status);
362 if (exitstatus != 0)
363 {
364 fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus);
365 return 5;
366 }
367 return 0;
368}
369
370static int
371child_main (void)
372{
373 char buf[1024];
374
375 /* See if reading from STDIN_FILENO yields the expected contents. */
376 if (fread (buf, 1, sizeof (buf), stdin) == 11
377 && memcmp (buf, "Halle Potta", 11) == 0)
378 return 0;
379 else
380 return 8;
381}
382
383static void
384cleanup_then_die (int sig)
385{
386 /* Clean up data file. */
387 unlink (DATA_FILENAME);
388
389 /* Re-raise the signal and die from it. */
390 signal (sig, SIG_DFL);
391 raise (sig);
392}
393
394int
395main (int argc, char *argv[])
396{
397 int exitstatus;
398
399 if (!(argc > 1 && strcmp (argv[1], "-child") == 0))
400 {
401 /* This is the parent process. */
402 signal (SIGINT, cleanup_then_die);
403 signal (SIGTERM, cleanup_then_die);
404 #ifdef SIGHUP
405 signal (SIGHUP, cleanup_then_die);
406 #endif
407
408 exitstatus = parent_main ();
409 }
410 else
411 {
412 /* This is the child process. */
413
414 exitstatus = child_main ();
415 }
416 unlink (DATA_FILENAME);
417 return exitstatus;
418}
419]])],
420 [],
421 [gl_cv_func_posix_spawn_works=no])
422 fi
423 else
424 case "$host_os" in
425 aix*) gl_cv_func_posix_spawn_works="guessing no";;
426 *) gl_cv_func_posix_spawn_works="guessing yes";;
427 esac
428 fi
429 ])
430])
431
432dnl Test whether posix_spawn and posix_spawnp are secure.
433AC_DEFUN([gl_POSIX_SPAWN_SECURE],
434[
435 AC_REQUIRE([AC_PROG_CC])
436 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
437 dnl On many platforms, posix_spawn or posix_spawnp allow executing a
438 dnl script without a '#!' marker as a shell script. This is unsecure.
439 AC_CACHE_CHECK([whether posix_spawn rejects scripts without shebang],
440 [gl_cv_func_posix_spawn_secure_exec],
441 [echo ':' > conftest.scr
442 chmod a+x conftest.scr
443 AC_RUN_IFELSE([AC_LANG_SOURCE([[
444 #include <errno.h>
445 #include <spawn.h>
446 #include <stddef.h>
447 #include <sys/types.h>
448 #include <sys/wait.h>
449 int
450 main ()
451 {
452 const char *prog_path = "./conftest.scr";
453 const char *prog_argv[2] = { prog_path, NULL };
454 const char *environment[2] = { "PATH=.", NULL };
455 pid_t child;
456 int status;
457 int err = posix_spawn (&child, prog_path, NULL, NULL,
458 (char **) prog_argv, (char **) environment);
459 if (err == ENOEXEC)
460 return 0;
461 if (err != 0)
462 return 1;
463 status = 0;
464 while (waitpid (child, &status, 0) != child)
465 ;
466 if (!WIFEXITED (status))
467 return 2;
468 if (WEXITSTATUS (status) != 127)
469 return 3;
470 return 0;
471 }
472 ]])],
473 [gl_cv_func_posix_spawn_secure_exec=yes],
474 [gl_cv_func_posix_spawn_secure_exec=no],
475 [case "$host_os" in
476 # Guess no on GNU/Hurd.
477 gnu*)
478 gl_cv_func_posix_spawn_secure_exec="guessing no" ;;
479 # Guess yes on all other platforms.
480 *)
481 gl_cv_func_posix_spawn_secure_exec="guessing yes" ;;
482 esac
483 ])
484 rm -f conftest.scr
485 ])
486 AC_CACHE_CHECK([whether posix_spawnp rejects scripts without shebang],
487 [gl_cv_func_posix_spawnp_secure_exec],
488 [echo ':' > conftest.scr
489 chmod a+x conftest.scr
490 AC_RUN_IFELSE([AC_LANG_SOURCE([[
491 #include <errno.h>
492 #include <spawn.h>
493 #include <stddef.h>
494 #include <sys/types.h>
495 #include <sys/wait.h>
496 int
497 main ()
498 {
499 const char *prog_path = "./conftest.scr";
500 const char *prog_argv[2] = { prog_path, NULL };
501 const char *environment[2] = { "PATH=.", NULL };
502 pid_t child;
503 int status;
504 int err = posix_spawnp (&child, prog_path, NULL, NULL,
505 (char **) prog_argv, (char **) environment);
506 if (err == ENOEXEC)
507 return 0;
508 if (err != 0)
509 return 1;
510 status = 0;
511 while (waitpid (child, &status, 0) != child)
512 ;
513 if (!WIFEXITED (status))
514 return 2;
515 if (WEXITSTATUS (status) != 127)
516 return 3;
517 return 0;
518 }
519 ]])],
520 [gl_cv_func_posix_spawnp_secure_exec=yes],
521 [gl_cv_func_posix_spawnp_secure_exec=no],
522 [case "$host_os" in
523 # Guess yes on glibc systems (glibc >= 2.15 actually) except GNU/Hurd,
524 # musl libc, NetBSD.
525 *-gnu* | *-musl* | netbsd*)
526 gl_cv_func_posix_spawnp_secure_exec="guessing yes" ;;
527 # Guess no on GNU/Hurd, macOS, FreeBSD, OpenBSD, AIX, Solaris, Cygwin.
528 gnu* | darwin* | freebsd* | dragonfly* | openbsd* | aix* | solaris* | cygwin*)
529 gl_cv_func_posix_spawnp_secure_exec="guessing no" ;;
530 # If we don't know, obey --enable-cross-guesses.
531 *)
532 gl_cv_func_posix_spawnp_secure_exec="$gl_cross_guess_normal" ;;
533 esac
534 ])
535 rm -f conftest.scr
536 ])
537])
538
539# Prerequisites of lib/spawni.c.
540AC_DEFUN([gl_PREREQ_POSIX_SPAWN_INTERNAL],
541[
542 AC_CHECK_HEADERS([paths.h])
543 AC_CHECK_FUNCS([confstr sched_setparam sched_setscheduler setegid seteuid vfork])
544])
545
546AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE],
547[
548 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
549 AC_REQUIRE([AC_PROG_CC])
550 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
551 gl_POSIX_SPAWN
552 if test $REPLACE_POSIX_SPAWN = 1; then
553 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1
554 else
555 dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addclose
556 dnl succeeds even if the fd argument is out of range.
557 AC_CACHE_CHECK([whether posix_spawn_file_actions_addclose works],
558 [gl_cv_func_posix_spawn_file_actions_addclose_works],
559 [AC_RUN_IFELSE(
560 [AC_LANG_SOURCE([[
561#include <spawn.h>
562int main ()
563{
564 posix_spawn_file_actions_t actions;
565 if (posix_spawn_file_actions_init (&actions) != 0)
566 return 1;
567 if (posix_spawn_file_actions_addclose (&actions, 10000000) == 0)
568 return 2;
569 return 0;
570}]])],
571 [gl_cv_func_posix_spawn_file_actions_addclose_works=yes],
572 [gl_cv_func_posix_spawn_file_actions_addclose_works=no],
573 [# Guess no on musl libc and Solaris, yes otherwise.
574 case "$host_os" in
575 *-musl*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
576 solaris*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
577 # Guess no on native Windows.
578 mingw*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
579 *) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing yes" ;;
580 esac
581 ])
582 ])
583 case "$gl_cv_func_posix_spawn_file_actions_addclose_works" in
584 *yes) ;;
585 *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1 ;;
586 esac
587 fi
588])
589
590AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2],
591[
592 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
593 AC_REQUIRE([AC_PROG_CC])
594 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
595 gl_POSIX_SPAWN
596 if test $REPLACE_POSIX_SPAWN = 1; then
597 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1
598 else
599 dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_adddup2
600 dnl succeeds even if the fd argument is out of range.
601 AC_CACHE_CHECK([whether posix_spawn_file_actions_adddup2 works],
602 [gl_cv_func_posix_spawn_file_actions_adddup2_works],
603 [AC_RUN_IFELSE(
604 [AC_LANG_SOURCE([[
605#include <spawn.h>
606int main ()
607{
608 posix_spawn_file_actions_t actions;
609 if (posix_spawn_file_actions_init (&actions) != 0)
610 return 1;
611 if (posix_spawn_file_actions_adddup2 (&actions, 10000000, 2) == 0)
612 return 2;
613 return 0;
614}]])],
615 [gl_cv_func_posix_spawn_file_actions_adddup2_works=yes],
616 [gl_cv_func_posix_spawn_file_actions_adddup2_works=no],
617 [# Guess no on musl libc and Solaris, yes otherwise.
618 case "$host_os" in
619 *-musl*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";;
620 solaris*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";;
621 # Guess no on native Windows.
622 mingw*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no" ;;
623 *) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing yes";;
624 esac
625 ])
626 ])
627 case "$gl_cv_func_posix_spawn_file_actions_adddup2_works" in
628 *yes) ;;
629 *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1 ;;
630 esac
631 fi
632])
633
634AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN],
635[
636 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
637 AC_REQUIRE([AC_PROG_CC])
638 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
639 gl_POSIX_SPAWN
640 if test $REPLACE_POSIX_SPAWN = 1; then
641 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1
642 else
643 dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addopen
644 dnl succeeds even if the fd argument is out of range.
645 AC_CACHE_CHECK([whether posix_spawn_file_actions_addopen works],
646 [gl_cv_func_posix_spawn_file_actions_addopen_works],
647 [AC_RUN_IFELSE(
648 [AC_LANG_SOURCE([[
649#include <spawn.h>
650#include <fcntl.h>
651int main ()
652{
653 posix_spawn_file_actions_t actions;
654 if (posix_spawn_file_actions_init (&actions) != 0)
655 return 1;
656 if (posix_spawn_file_actions_addopen (&actions, 10000000, "foo", 0, O_RDONLY)
657 == 0)
658 return 2;
659 return 0;
660}]])],
661 [gl_cv_func_posix_spawn_file_actions_addopen_works=yes],
662 [gl_cv_func_posix_spawn_file_actions_addopen_works=no],
663 [# Guess no on musl libc and Solaris, yes otherwise.
664 case "$host_os" in
665 *-musl*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";;
666 solaris*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";;
667 # Guess no on native Windows.
668 mingw*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no" ;;
669 *) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing yes";;
670 esac
671 ])
672 ])
673 case "$gl_cv_func_posix_spawn_file_actions_addopen_works" in
674 *yes) ;;
675 *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1 ;;
676 esac
677 fi
678])
diff --git a/m4/posix_spawn_faction_addchdir.m4 b/m4/posix_spawn_faction_addchdir.m4
new file mode 100644
index 00000000000..1ce7153d1d1
--- /dev/null
+++ b/m4/posix_spawn_faction_addchdir.m4
@@ -0,0 +1,20 @@
1# posix_spawn_faction_addchdir.m4 serial 1
2dnl Copyright (C) 2018-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR],
8[
9 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
10 AC_REQUIRE([AC_PROG_CC])
11 gl_POSIX_SPAWN
12 AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir posix_spawn_file_actions_addchdir_np])
13 if test $ac_cv_func_posix_spawn_file_actions_addchdir = yes; then
14 dnl This function is not yet standardized. Therefore override the
15 dnl system's implementation always.
16 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1
17 else
18 HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0
19 fi
20])
diff --git a/m4/sched_h.m4 b/m4/sched_h.m4
new file mode 100644
index 00000000000..af0c43de079
--- /dev/null
+++ b/m4/sched_h.m4
@@ -0,0 +1,91 @@
1# sched_h.m4 serial 12
2dnl Copyright (C) 2008-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Written by Bruno Haible.
8
9AC_DEFUN([gl_SCHED_H],
10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
12 dnl once only, before all statements that occur in other macros.
13 AC_REQUIRE([gl_SCHED_H_DEFAULTS])
14
15 AC_REQUIRE([AC_CANONICAL_HOST])
16
17 AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
18 AC_CHECK_HEADERS([sched.h], [], [],
19 [[#if HAVE_SYS_CDEFS_H
20 #include <sys/cdefs.h>
21 #endif
22 ]])
23 gl_NEXT_HEADERS([sched.h])
24
25 if test "$ac_cv_header_sched_h" = yes; then
26 HAVE_SCHED_H=1
27 else
28 HAVE_SCHED_H=0
29 fi
30 AC_SUBST([HAVE_SCHED_H])
31
32 if test "$HAVE_SCHED_H" = 1; then
33 AC_CHECK_TYPE([struct sched_param],
34 [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0],
35 [[#if HAVE_SYS_CDEFS_H
36 #include <sys/cdefs.h>
37 #endif
38 #include <sched.h>
39 ]])
40 else
41 HAVE_STRUCT_SCHED_PARAM=0
42 case "$host_os" in
43 os2*)
44 dnl On OS/2 kLIBC, struct sched_param is in spawn.h.
45 AC_CHECK_TYPE([struct sched_param],
46 [HAVE_STRUCT_SCHED_PARAM=1], [],
47 [#include <spawn.h>])
48 ;;
49 vms)
50 dnl On OpenVMS 7.2 or newer, struct sched_param is in pthread.h.
51 AC_CHECK_TYPE([struct sched_param],
52 [HAVE_STRUCT_SCHED_PARAM=1], [],
53 [#include <pthread.h>])
54 ;;
55 esac
56 fi
57 AC_SUBST([HAVE_STRUCT_SCHED_PARAM])
58
59 if test "$ac_cv_header_sys_cdefs_h" = yes; then
60 HAVE_SYS_CDEFS_H=1
61 else
62 HAVE_SYS_CDEFS_H=0
63 fi
64 AC_SUBST([HAVE_SYS_CDEFS_H])
65
66 dnl Ensure the type pid_t gets defined.
67 AC_REQUIRE([AC_TYPE_PID_T])
68
69 dnl Check for declarations of anything we want to poison if the
70 dnl corresponding gnulib module is not in use, if it is not common
71 dnl enough to be declared everywhere.
72 gl_WARN_ON_USE_PREPARE([[#include <sched.h>
73 ]], [sched_yield])
74])
75
76AC_DEFUN([gl_SCHED_MODULE_INDICATOR],
77[
78 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
79 AC_REQUIRE([gl_SCHED_H_DEFAULTS])
80 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
81 dnl Define it also as a C macro, for the benefit of the unit tests.
82 gl_MODULE_INDICATOR_FOR_TESTS([$1])
83])
84
85AC_DEFUN([gl_SCHED_H_DEFAULTS],
86[
87 GNULIB_SCHED_YIELD=0; AC_SUBST([GNULIB_SCHED_YIELD])
88 dnl Assume proper GNU behavior unless another module says otherwise.
89 HAVE_SCHED_YIELD=1; AC_SUBST([HAVE_SCHED_YIELD])
90 REPLACE_SCHED_YIELD=0; AC_SUBST([REPLACE_SCHED_YIELD])
91])
diff --git a/m4/sh-filename.m4 b/m4/sh-filename.m4
new file mode 100644
index 00000000000..f7b31548e0d
--- /dev/null
+++ b/m4/sh-filename.m4
@@ -0,0 +1,22 @@
1# sh-filename.m4 serial 2
2dnl Copyright (C) 2018-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_DEFUN([gl_SH_FILENAME],
10[
11 AH_VERBATIM([SH_FILENAME],
12[/* File name of the Bourne shell. */
13#if defined __CYGWIN__ || defined __ANDROID__
14/* Omit the directory part because
15 - For 32-bit Cygwin programs in a 64-bit Cygwin environment, the Cygwin
16 mounts are not visible.
17 - On Android, /bin/sh does not exist. It's /system/bin/sh instead. */
18# define BOURNE_SHELL "sh"
19#else
20# define BOURNE_SHELL "/bin/sh"
21#endif])
22])
diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4
new file mode 100644
index 00000000000..781f9f49652
--- /dev/null
+++ b/m4/spawn_h.m4
@@ -0,0 +1,136 @@
1# spawn_h.m4 serial 18
2dnl Copyright (C) 2008-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Written by Bruno Haible.
8
9AC_DEFUN([gl_SPAWN_H],
10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
12 dnl once only, before all statements that occur in other macros.
13 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
14
15 dnl <spawn.h> is always overridden, because of GNULIB_POSIXCHECK.
16 gl_CHECK_NEXT_HEADERS([spawn.h])
17
18 if test $ac_cv_header_spawn_h = yes; then
19 HAVE_SPAWN_H=1
20 AC_CHECK_TYPES([posix_spawnattr_t], [], [HAVE_POSIX_SPAWNATTR_T=0], [[
21#include <spawn.h>
22 ]])
23 AC_CHECK_TYPES([posix_spawn_file_actions_t], [],
24 [HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0], [[
25#include <spawn.h>
26 ]])
27 else
28 HAVE_SPAWN_H=0
29 HAVE_POSIX_SPAWNATTR_T=0
30 HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0
31 fi
32 AC_SUBST([HAVE_SPAWN_H])
33
34 dnl Ensure the type pid_t gets defined.
35 AC_REQUIRE([AC_TYPE_PID_T])
36
37 dnl Ensure the type mode_t gets defined.
38 AC_REQUIRE([AC_TYPE_MODE_T])
39
40 AC_REQUIRE([gl_HAVE_POSIX_SPAWN])
41
42 AC_REQUIRE([AC_C_RESTRICT])
43
44 dnl Check for declarations of anything we want to poison if the
45 dnl corresponding gnulib module is not in use.
46 gl_WARN_ON_USE_PREPARE([[#include <spawn.h>
47 ]], [posix_spawn posix_spawnp posix_spawnattr_init posix_spawnattr_destroy
48 posix_spawnattr_getsigdefault posix_spawnattr_setsigdefault
49 posix_spawnattr_getsigmask posix_spawnattr_setsigmask
50 posix_spawnattr_getflags posix_spawnattr_setflags
51 posix_spawnattr_getpgroup posix_spawnattr_setpgroup
52 posix_spawnattr_getschedpolicy posix_spawnattr_setschedpolicy
53 posix_spawnattr_getschedparam posix_spawnattr_setschedparam
54 posix_spawn_file_actions_init posix_spawn_file_actions_destroy
55 posix_spawn_file_actions_addopen posix_spawn_file_actions_addclose
56 posix_spawn_file_actions_adddup2 posix_spawn_file_actions_addchdir
57 posix_spawn_file_actions_addfchdir])
58])
59
60dnl Checks whether the system has the functions posix_spawn.
61dnl Sets ac_cv_func_posix_spawn and HAVE_POSIX_SPAWN.
62AC_DEFUN([gl_HAVE_POSIX_SPAWN],
63[
64 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
65 dnl once only, before all statements that occur in other macros.
66 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
67
68 LIB_POSIX_SPAWN=
69 AC_SUBST([LIB_POSIX_SPAWN])
70 gl_saved_libs=$LIBS
71 AC_SEARCH_LIBS([posix_spawn], [rt],
72 [test "$ac_cv_search_posix_spawn" = "none required" ||
73 LIB_POSIX_SPAWN=$ac_cv_search_posix_spawn])
74 AC_CHECK_FUNCS([posix_spawn])
75 LIBS=$gl_saved_libs
76
77 if test $ac_cv_func_posix_spawn != yes; then
78 HAVE_POSIX_SPAWN=0
79 fi
80])
81
82AC_DEFUN([gl_SPAWN_MODULE_INDICATOR],
83[
84 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
85 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
86 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
87 dnl Define it also as a C macro, for the benefit of the unit tests.
88 gl_MODULE_INDICATOR_FOR_TESTS([$1])
89])
90
91AC_DEFUN([gl_SPAWN_H_DEFAULTS],
92[
93 GNULIB_POSIX_SPAWN=0; AC_SUBST([GNULIB_POSIX_SPAWN])
94 GNULIB_POSIX_SPAWNP=0; AC_SUBST([GNULIB_POSIX_SPAWNP])
95 GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT])
96 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
97 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
98 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
99 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR])
100 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])
101 GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY])
102 GNULIB_POSIX_SPAWNATTR_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_INIT])
103 GNULIB_POSIX_SPAWNATTR_GETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETFLAGS])
104 GNULIB_POSIX_SPAWNATTR_SETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETFLAGS])
105 GNULIB_POSIX_SPAWNATTR_GETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETPGROUP])
106 GNULIB_POSIX_SPAWNATTR_SETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETPGROUP])
107 GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM])
108 GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM])
109 GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY])
110 GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY])
111 GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT])
112 GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT])
113 GNULIB_POSIX_SPAWNATTR_GETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGMASK])
114 GNULIB_POSIX_SPAWNATTR_SETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGMASK])
115 GNULIB_POSIX_SPAWNATTR_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_DESTROY])
116 dnl Assume proper GNU behavior unless another module says otherwise.
117 HAVE_POSIX_SPAWN=1; AC_SUBST([HAVE_POSIX_SPAWN])
118 HAVE_POSIX_SPAWNATTR_T=1; AC_SUBST([HAVE_POSIX_SPAWNATTR_T])
119 HAVE_POSIX_SPAWN_FILE_ACTIONS_T=1;
120 AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T])
121 HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1;
122 AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
123 HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=1;
124 AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR])
125 REPLACE_POSIX_SPAWN=0; AC_SUBST([REPLACE_POSIX_SPAWN])
126 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0;
127 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
128 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0;
129 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
130 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0;
131 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
132 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0;
133 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR])
134 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0;
135 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])
136])
diff --git a/m4/strchrnul.m4 b/m4/strchrnul.m4
new file mode 100644
index 00000000000..a18f0935a51
--- /dev/null
+++ b/m4/strchrnul.m4
@@ -0,0 +1,50 @@
1# strchrnul.m4 serial 9
2dnl Copyright (C) 2003, 2007, 2009-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_STRCHRNUL],
8[
9 dnl Persuade glibc <string.h> to declare strchrnul().
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11
12 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
13 AC_CHECK_FUNCS([strchrnul])
14 if test $ac_cv_func_strchrnul = no; then
15 HAVE_STRCHRNUL=0
16 else
17 AC_CACHE_CHECK([whether strchrnul works],
18 [gl_cv_func_strchrnul_works],
19 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
20#include <string.h> /* for strchrnul */
21]], [[const char *buf = "a";
22 return strchrnul (buf, 'b') != buf + 1;
23 ]])],
24 [gl_cv_func_strchrnul_works=yes],
25 [gl_cv_func_strchrnul_works=no],
26 [dnl Cygwin 1.7.9 introduced strchrnul, but it was broken until 1.7.10
27 AC_EGREP_CPP([Lucky user],
28 [
29#if defined __CYGWIN__
30 #include <cygwin/version.h>
31 #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 9)
32 Lucky user
33 #endif
34#else
35 Lucky user
36#endif
37 ],
38 [gl_cv_func_strchrnul_works="guessing yes"],
39 [gl_cv_func_strchrnul_works="guessing no"])
40 ])
41 ])
42 case "$gl_cv_func_strchrnul_works" in
43 *yes) ;;
44 *) REPLACE_STRCHRNUL=1 ;;
45 esac
46 fi
47])
48
49# Prerequisites of lib/strchrnul.c.
50AC_DEFUN([gl_PREREQ_STRCHRNUL], [:])