Bug #3268


parent process does not receive POLLHUP events

Added by mikdusan over 1 year ago. Updated over 1 year ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


The attached `main.c` code is a reduction which takes as args, a command (absolute path) to fork/exec and poll stdout/stderr. POLLHUP events should be issued for both pipes when the child is finished.

For the Zig project we have this implemented in the zig language but I've provided a similar .c implementation since it was already done during my triage. For both .zig and .c code, linux, macos, freebsd, netbsd, openbsd work as expected and dragonfly manifests this unexpected behaviour of not receiving POLLHUP.

In the provided reduction, the bug manifests as an infinite loop after reading the bytes from child stdout/stderr. The parent keeps getting POLLIN events, and the read keeps returning 0 nbytes read which indicate the pipe has been closed. In the interim I will likely workaround this bug with conditional code for dragonfly to key off nbytes=0.

I have reproduced the bug on dragonfly 5.8, 6.0 and 5.0.0 (the oldest .iso I could find).


main.c (3.2 KB) main.c mikdusan, 05/09/2021 09:08 AM
pollhup01.patch (357 Bytes) pollhup01.patch dillon, 05/10/2021 05:02 PM
pollhup02.patch (1.86 KB) pollhup02.patch dillon, 05/10/2021 05:16 PM
Actions #1

Updated by dillon over 1 year ago

Please try the included patch. I did a quick test and it appears to work.

Currently only the socket code allows POLLHUP to be set. This patch will also enable it for the pipe code. And if it looks good I should probably also implement the same thing for the fifo code.


Actions #2

Updated by dillon over 1 year ago

pollhup02.patch is a more complete patch (also removes unrelated cruft that was in my tree). It patches the read and write side for pipes and for filesystem fifos.


Actions #3

Updated by mikdusan over 1 year ago

confirmed : pollhup02.patch fixes issue for me:

  • applied against DragonFly_RELEASE_6_0
  • main.c now works
  • zig std.ChildProcess.exec() now works

Thank you much Matt!

Actions #4

Updated by tuxillo over 1 year ago

  • Target version changed from 6.2 to 6.0
  • % Done changed from 0 to 100
Actions #5

Updated by dillon over 1 year ago

  • Status changed from In Progress to Resolved

Ok, excellent. I have pushed the patch to 6.0-release and master. Going to close the bug. Thanks!


Actions #6

Updated by tuxillo over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF