:: Re: [DNG] vdev status update in dae…
Top Page
Delete this message
Reply to this message
Author: Rainer Weikusat
Date:  
To: dng
Subject: Re: [DNG] vdev status update in daedalus
Didier Kryn <kryn@???> writes:
> Le 17/07/2025 à 00:43, aitor a écrit :
>> For a long time the "struct pollfd pfd" defined in the line 56 of
>> linux.c:
>> https://github.com/jcnelson/vdev/blob/master/vdevd/os/linux.h
>> consists of a poll dealing with several file descriptors. I'll add
>> another one to handle the pipe you mentioned above. For example: /*
>> ------------------ CODE ---------------------------- */
>>
>> // Enumerate list of FDs to poll
>> enum {
>>         FD_POLL_SIGNAL = 0,
>>         FD_POLL_PIPE,
>>         FD_POLL_NETLINK,
>>         FD_POLL_MAX
>> };


This means FD_POLL_PIPE has the value 1.

[...]

>         /* Setup the polling part concerning to the pipe, and the
>> rest as well */
>>         pfd[FD_POLL_PIPE].fd = pipe[1];
>>         pfd[FD_POLL_PIPE].events = POLLIN;
>>         ( .... )
>>
>
>     I have a doubt about which end of the pipe you poll: it seems you
> poll the write end instead of the read end.


Which means this is polling the write end of the pipe on systems where
pipes are indeed unidirectional. The convention is the same here as for
standard I/O file descriptors. File descriptor 0 is the standard input
and 1 is the standard output. When creating a pipe, the first file
descriptor (offset 0) is for reading and the second one for writing.