I'm writing a small program which is somewhat a server that spawns its client programs (locally, not over the network) and do interesting things between them. While my primary OS in use is Linux, I expect this to run on other OSes including Windows. There is fork
and exec
which does the job, but when I port the program to Windows via cygwin, I don't want that crappy fork
implemented in cygwin to kick in, which actually calls CreateProcess
and copies the current process's memory area to the new process using setjmp
/longjmp
with shared memory mutexes, all of this in order to be replaced with another program (exec
). While reading the FAQ page of cygwin I discovered spawn.h
and its posix_spawn
, which basically looks like CreatePorcess(Ex)
in windows. It seems like a new feature (... I mean not one of the original UNIX system functions), so I have some questions upon it.
Is it implemented well, widely? (I saw some posts on the internet that it is not defined under his/her system.)
Can I expect any performance improvement or deterioration by using
posix_spawn
instead offork
/exec
in Linux?Why is
posix_spawn
less known and less used thanfork
/exec
although being standard since 1999?