On Jul 22 14:41, Eric Blake wrote: > Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes: > > > > > Do you have a working C testcase to demonstrate this? > > I still haven't gotten around to trying your patch, but here is the testcase > I'm using (I guess it's not that simple, after all): > [...testcase...] > For an example of some of the bugs (which I hope your latest patch attempt > fixes): > > $ ./foo 4& sleep 2; ./foo 0 > [1] 21692 > ./foo pid 21692 starting > ./foo pid 21692 got lock > ./foo pid 21704 forked from 21692 > ./foo pid 21704 unlocked > ./foo pid 14060 starting > ./foo pid 14060 got lock > ./foo pid 21216 forked from 14060 > ./foo pid 21704 exiting > ./foo pid 21692 exiting > ./foo pid 21216 exiting > ./foo pid 14060 exiting > [1]+ Done ./foo 4 > > Oops - process 14060 got the lock before 12692 and 21704 exited.
This looks different with my patch: $ ./foo 0 ./foo pid 2712 starting ./foo pid 2712 got lock ./foo pid 748 forked from 2712 ./foo pid 748 exiting ./foo pid 2712 exiting $ ./foo 0 ./foo pid 2616 starting ./foo pid 2616 got lock ./foo pid 2892 forked from 2616 ./foo pid 2892 exiting ./foo pid 2616 exiting > $ ./foo 15 > ./foo pid 10932 starting > ./foo pid 10932 protected fd > ./foo pid 10932 got lock > ./foo pid 10932 closed > ./foo pid 26264 forked from 10932 > ./foo pid 26264 unlocked > ./foo pid 26264 execing > ./foo pid 26264 exiting > ./foo pid 10932 exiting > > Oops - process 26264 successfully unlocked fd, even though it was marked > close- > on-exec by 10932 before the fork. Well, sure, it has been marked close-on-exec, but this doesn't mean the descriptor is invalid after the fork. AFAICS it's perfectly valid for the forked child 26264 to unlock the BSD lock. What am I missing? Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- 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