An idea I proposed on cygwin-devel that I intended to look at for 3.7, and which came up again with rustc having dll base conflicts, I started looking at optimizing posix_spawn to use spawn instead of fork/exec where it's already more-or-less possible. I did add the ability to redirect stderr in ch_spawn.worker, as was already done for stdin and stdout, since that was used by rust and apparently by llvm. I have not handled any of the spawnattr flags or (f)chdir, but it feels like they shouldn't be too horribly difficult to deal with (particularly chdir since CreateProcessW can take a current directory parameter).
The ugliness of this is that I had to copy/paste some structs from newlib/libc/posix/posix_spawn.c to access the file actions. Jeremy Drake (3): Cygwin: allow redirecting stderr in ch_spawn Cygwin: hook posix_spawn/posix_spawnp Cygwin: add fast-path for posix_spawn(p) winsup/cygwin/cygwin.din | 4 +- winsup/cygwin/dcrt0.cc | 2 + winsup/cygwin/local_includes/child_info.h | 6 +- winsup/cygwin/spawn.cc | 167 +++++++++++++++++++++- 4 files changed, 172 insertions(+), 7 deletions(-) -- 2.49.0.windows.1
