https://github.com/labath approved this pull request.

> I made a sample binary 
> (https://gist.github.com/ashgti/1649fde8ef28783ace1e414f87a6b680) and it 
> seems stdin is opened as an anonymous pipe.

Got it. Thanks for checking it out. I guess we have no choice, but to create 
the extra thread. It's unfortunate that windows doesn't allow you to do async 
I/O if the file handle wasn't created as such. The "just create it the right 
way from the start" argument makes sense when everything happens within a 
single process, but this use case (passing a pipe handle from one process to 
another) is kind of a counterexample to that.

I also wouldn't be surprised if we needed to add threads to wait for other 
kinds of events in the future. One thing that would be occasionally useful to 
do is to wait for some data to arrive (e.g. a process writes something to a 
pipe) *OR* for a process to die (e.g. the writing process crashes). Linux can 
pull that off without threads using a pidfd, but I'm not sure all systems can.

It's also reassuring to know that we can avoid the extra thread if we need to 
for pipes we have create ourselves, but I think we don't need to do that now. I 
think most of the internal uses of pipes would be better off by switching to 
`AddPendingCallback` (which internally uses a pipe on posix, but directly 
signals an event on windows).

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

Reply via email to