fork() fails if it is called recursively from a child thread.

Takashi Yano takashi.yano@nifty.ne.jp
Thu Mar 9 11:40:00 GMT 2017


Hello,

I found fork() fails if it is called recursively from a child thread.

Simple test case, attached (fk.c), reproduces this problem.

Expected result:
Parent 0 [22034] exit.
Child 0 [22036] works.
Parent 1 [22036] exit.
Child 1 [22038] works.
Parent 2 [22038] exit.
Child 2 [22039] works.
Parent 3 [22039] exit.
Child 3 [22040] works.
Parent 4 [22040] exit.
Child 4 [22041] works.

Result in cygwin 2.7.0:
Child 0 [4668] works.
Parent 0 [7188] exit.
      0 [main] a 4668 fork: child -1 - forked process 8456 died unexpectedly, retry 0, exit code 0xC0000142, errno 11
fork(): Resource temporarily unavailable

Strictly speaking, the test case is not safe because it calls functions
which are not async-signal-safe from forked child process, i.e. printf()
and perror(), in spite of multi-thread. However the same happens even
without printf() and perror().

This is the cause of which iperf 2.0.5 with option -s -D fails to start
as daemon.

Is this the known issue?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fk.c
Type: text/x-csrc
Size: 550 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20170309/333659da/attachment.bin>
-------------- next part --------------

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list