The attached patches implement posix_spawn and posix_spawnp for native Windows. To my knowledge, it's a world's first. While the posix_spawn facility was designed to be portable to other operating systems [1], the mingw people did not and do not provide it. [1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html section "RATIONALE" 2020-12-24 Bruno Haible posix_spawn-internal: Implement for native Windows. * lib/spawni.c (grow_inheritable_handles, shrink_inheritable_handles, close_inheritable_handles, memiszero, sigisempty, open_handle, do_open, do_dup2, do_close): New functions. (__spawni): Implement on native Windows. * modules/posix_spawn-internal (Depends-on): Add filename, concat-filename, findprog-in, malloca, windows-spawn. * doc/posix-functions/posix_spawn.texi: Update. * doc/posix-functions/posix_spawnp.texi: Likewise. 2020-12-24 Bruno Haible windows-spawn: Export another auxiliary function. * lib/windows-spawn.h (convert_CreateProcess_error): New declaration. * lib/windows-spawn.c (convert_CreateProcess_error): New function, extracted from spawnpvech. (spawnpvech): Use it. 2020-12-24 Bruno Haible windows-spawn: Export some more auxiliary functions. * lib/windows-spawn.h: Include . (struct inheritable_handles): New type. (init_inheritable_handles, compose_handles_block, free_inheritable_handles): New declarations. * lib/windows-spawn.c (init_inheritable_handles, compose_handles_block): New functions, based on spawnvech. (free_inheritable_handles): New function. (spawnpvech): Use them. 2020-12-24 Bruno Haible windows-spawn: Export another auxiliary function. * lib/windows-spawn.h (compose_envblock): New declaration. * lib/windows-spawn.c (compose_envblock): New function, extracted from spawnpvech. (spawnpvech): Use it. 2020-12-24 Bruno Haible windows-spawn: Export an auxiliary function. * lib/windows-spawn.h (compose_command): New declaration. * lib/windows-spawn.c (compose_command): New function, extracted from spawnpvech. (spawnpvech): Use it. 2020-12-24 Bruno Haible posix_spawn* tests: Add support for native Windows. * tests/test-posix_spawn-open1.c (DATA_FILENAME): Treat native Windows like Cygwin. * tests/test-posix_spawn-dup2-stdin.c (main): Don't assume the signals SIGHUP and SIGPIPE. On native Windows, don't call posix_spawnattr_setsigmask. * tests/test-posix_spawn-dup2-stdout.c (main): Likewise. * tests/test-posix_spawn-fchdir.c (main): Likewise. * tests/test-posix_spawn-chdir.c (test): Likewise. Accept the child output from Cygwin's 'pwd' program. * tests/test-posix_spawn-script.c (main): On native Windows, skip the executable-shell-script part of the test. * tests/test-posix_spawnp-script.c (main): Likewise. * modules/posix_spawn-tests (Depends-on): Add freopen, waitpid. (configure.ac): Don't define the POSIX_SPAWN_PORTED conditional. (Makefile.am): Don't test the POSIX_SPAWN_PORTED conditional. * modules/posix_spawnp-tests (Depends-on): Add waitpid. (configure.ac): Don't define the POSIX_SPAWN_PORTED conditional. (Makefile.am): Don't test the POSIX_SPAWN_PORTED conditional. * modules/posix_spawn_file_actions_addchdir-tests (Makefile.am): Don't test the POSIX_SPAWN_PORTED conditional. * modules/posix_spawn_file_actions_addfchdir-tests (configure.ac): Define the POSIX_SPAWN_PORTED conditional here. 2020-12-24 Bruno Haible sh-filename: Add support for native Windows. * m4/sh-filename.m4 (gl_SH_FILENAME): Treat native Windows like Cygwin.