labath wrote:

> * thread 1 opens a file for writing (file descriptor A) and starts writing it
> 
> * thread 2 starts launching a gdb server. It calls fork(), which creates 
> another process with a copy of fd A (the fd has the CLOEXEC flag set, but not 
> CLOFORK (the flag doesn't exist))
> 
> * thread 1 finishes writing, closes fd A (in its/parent process)
> 
> * thread 1launches gdb-server, gdb-server tries to launch the file it has 
> just written, gets ETXTBSY because the fd is still open in the child process

In this scenario, waiting does make the exec succeed, because the FD in the 
forked process will not stay open very long. It will get closed as soon as the 
process runs `execve` (due to CLOEXEC).

https://github.com/llvm/llvm-project/pull/100659
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to