According to explanation of spawn2(), spawn2() should inherit other handles as well as standard IOs if P_2_NOINHERIT nor P_2_XREDIR is given.
However, if P_2_THREADSAFE is given or simple redirection mode is used, only standard handles are inherited by a child process even if P_2_NOINEHRIT is not given.
For example, if fd is given no. 10 by open(), it's not inherited by a child. Of course, it's possible to use P_2_XREDIR to pass the fd to a child explicitly. However, when implementing spawn-like functions with spawn2(), it's not easy to control it.
I think, this is a mis-behavior and a different behavior from a explanation of spawn2(). This should be fixed.
Here is the testcase. Pass 0 to 5 to the executable. If argument is none, 0 is default.
mode no. - explanation: result
0 - no thread safe, no redir: PASS
1 - thread safe, no redir: FAIL
2 - no thread safe, simple no redir: PASS
3 - thread safe, simple no redir: FAIL
4 - no thread safe, simple redir: FAIL
5 - thread safe, simple redir: FAIL
Hi/2.
According to explanation of spawn2(), spawn2() should inherit other handles as well as standard IOs if P_2_NOINHERIT nor P_2_XREDIR is given.
However, if P_2_THREADSAFE is given or simple redirection mode is used, only standard handles are inherited by a child process even if P_2_NOINEHRIT is not given.
For example, if fd is given no. 10 by open(), it's not inherited by a child. Of course, it's possible to use P_2_XREDIR to pass the fd to a child explicitly. However, when implementing spawn-like functions with spawn2(), it's not easy to control it.
I think, this is a mis-behavior and a different behavior from a explanation of spawn2(). This should be fixed.
Here is the testcase. Pass 0 to 5 to the executable. If argument is none, 0 is default.
mode no. - explanation: result 0 - no thread safe, no redir:
PASS
1 - thread safe, no redir:FAIL
2 - no thread safe, simple no redir:PASS
3 - thread safe, simple no redir:FAIL
4 - no thread safe, simple redir:FAIL
5 - thread safe, simple redir:FAIL
cxspawninherit.c.txt