Hello,

yelninei--- via Bug reports for the GNU Hurd, le mer. 09 sept. 2026 18:52:28 
+0200, a ecrit:
> I just found the following bug.

> I think what is happening is that the pipe_wait_readable call in pipe_recv 
> sees that no data is available and fails with EWOULDBLOCK. I guess there 
> would need to be similar condition as in pipe_send as there is nothing to do 
> but I am not sure how it should look like.

Indeed! I have pushed the attached fix.

Thanks,
Samuel
commit 2106848bcf8adcc0a62d46e20af7e37a260f4f91
Author: Samuel Thibault <[email protected]>
Date:   Thu Sep 10 01:35:07 2026 +0200

    pflocal: Fix reading 0 bytes
    
    When requested to read 0 bytes, we should only check for errors and
    return 0 instead of trying to block.
    
    Thanks yelninei for the report!

diff --git a/libpipe/pipe.c b/libpipe/pipe.c
index 55ef773f4..ceb9b48b5 100644
--- a/libpipe/pipe.c
+++ b/libpipe/pipe.c
@@ -496,6 +496,17 @@ pipe_recv (struct pipe *pipe, int noblock, unsigned 
*flags, void **source,
   /* True if the user isn't asking for any `control' data.  */
   int data_only = (control == NULL && ports == NULL);
 
+  /* Nothing to do.  */
+  if (amount == 0)
+    {
+      *data_len = 0;
+      if (control_len)
+       *control_len = 0;
+      if (num_ports)
+       *num_ports = 0;
+      return 0;
+    }
+
   err = pipe_wait_readable (pipe, noblock, data_only);
   if (err)
     return err;

Reply via email to