- implementation using unix.Select (btw, I explicitly mentioned 
   unix.Select in my OP): 
   
https://github.com/siemens/cshargextcap/blob/2f45f96748e835f0fef4cf429ca27f92a6c60a33/pipe/checker_notwin.go
   - unit test producing this behavior, differing between Linux and macos: 
   
https://github.com/siemens/cshargextcap/blob/2f45f96748e835f0fef4cf429ca27f92a6c60a33/pipe/checker_notwin_test.go

That should suffice as a minimal example. "go test -v ./pipe -ginkgo.v" 
gives details as the test progresses.

On Saturday, December 16, 2023 at 6:40:01 AM UTC+1 Kurtis Rader wrote:

> Do not make us guess what your code looks like and which packages you are 
> using. I'm guessing you are using 
> https://pkg.go.dev/golang.org/x/sys/unix#Select but I shouldn't have to 
> do so. You should be able to show us a minimal reproducible example of code 
> that illustrates a problem of this nature.
>
> On Fri, Dec 15, 2023 at 7:13 AM 'TheDiveO' via golang-nuts <
> golan...@googlegroups.com> wrote:
>
>> Hi, I need to detect on the producer side (writing end) of a named pipe 
>> when the consumer (reading end) has disconnect/closed. This detection needs 
>> to work "quickly" even if the producer doesn't produce anything; thus, 
>> SIGPIPE wouldn't help.
>>
>> On Linux, when using unix.Select() on the fd of the producer's writing 
>> end of the named pipe, the fd becomes readable only upon the consumer 
>> disconnecting.
>>
>> On macos, unix.Select indicates that the writing end fd becomes readable 
>> as soon as the producer writes(!) data. But it never reports the fd 
>> becoming readable upon the consumer disconnecting.
>>
>> I'm opening both named pipe ends as follows (in different processes):
>>
>> os.OpenFile(fifoname, os.O_WRONLY, os.ModeNamedPipe)
>> os.OpenFile(fifoname, os.O_RDONLY, os.ModeNamedPipe)
>>
>>    - is there something to know of in Go's runtime/stdlib (and 
>>    especially the poller) that might interfere with my usage of unix.Select 
>> on 
>>    an ordinary *os.File?
>>    - how can I detect the consumer disconnecting on macos?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/3f8df371-4fda-44e2-8acb-b0743fb6b27en%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/3f8df371-4fda-44e2-8acb-b0743fb6b27en%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/dbcb1746-8984-406e-8211-ec60ce56d748n%40googlegroups.com.

Reply via email to