Date: Tue, 04 Jul 2023 23:09:26 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 272367] openat(..., O_NONBLOCK | O_EXLOCK) may wrongly return EAGAIN Message-ID: <bug-272367-227-Mfa6sCqWC6@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-272367-227@https.bugs.freebsd.org/bugzilla/> References: <bug-272367-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D272367 --- Comment #2 from Konstantin Belousov <kib@FreeBSD.org> --- Several preliminary facts: 1. posix_spawn is basically vfork + exec. 2. vfork does not stop other threads in the forked process 3. vfork copies file descriptor table, creating additional ref for each file 4. flock semantic is that the lock is dropped only on last close So what could happen in your program is that some thread A has opened and locked its file. while thread B called posix_spawn(). Forked child now shares the reference to the file of thread A. Thread A closes the file and tries to open it again, which would block on the old lock still existing due to ref in the child of the thread B. That's it. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-272367-227-Mfa6sCqWC6>