<div dir="ltr">On linux when you call fork the new process will only have the thread what called fork. Other threads will be ignored with leaving whatever dirty state they had left in the new process. Regarding execve it doesn't do fork so we would have to do fork & execve what have the same issue (actually we are using execve as of now but it isn't different from exec in this regard).<div><br></div><div>Tamas</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 16, 2017 at 1:57 PM Zachary Turner via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Oct 15, 2017 at 3:15 PM Pavel Labath <<a href="mailto:labath@google.com" target="_blank">labath@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 15 October 2017 at 23:04, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> Doesn’t DisableAllLogChannels acquire a scoped lock? If so wouldn’t it just<br>
> release at the end of the function?<br>
<br>
<br>
The thing is, it is unable to acquire the lock in the first place,<br>
because the mutex is already "locked". So, the sequence of events is<br>
process 1, thread 1: acquire lock<br>
process 1, thread 2: fork(), process 2 is created<br>
process 1 thread 1: release lock<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>Suppose process 1 thread 1 had been executing this code:</div><div>```</div><div>lock();</div><div>logSomething();  // thread 2 forks when thread 1 is here.</div><div>unlock();</div><div>```</div><div><br></div><div>Doesn't thread 2 in the child process resume running from the same point?  If so, it seems that both the child and parent would both gracefully unlock the lock.</div><div><br></div><div>I'm sure I'm wrong about this, but hopefully you can clarify what I'm missing.</div><div><br></div><div>As a follow-up question, why can't we use execve instead of fork / exec?</div></div></div>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>