bugfix/hanging-background-processes #54

Merged
darthrubik merged 4 commits from bugfix/hanging-background-processes into master 2026-08-12 16:08:30 -05:00
Owner
No description provided.
darthrubik added 3 commits 2026-08-12 16:01:20 -05:00
The shell tool would hang indefinitely when running commands that spawn
background processes (e.g., 'sleep 10 &'). This was because:

1. Background processes inherit stdout, which points to our pipe
2. The original code read in a loop when POLLIN was detected
3. After reading available data, the second read() would block waiting
   for more data that never comes (since background process just sleeps)

The fix changes the POLLIN handler to read only once, then continue
polling. If POLLHUP is eventually set (when the background process is
killed by timeout), we'll read all remaining data then.

Additionally, FD_CLOEXEC is set on pipe file descriptors to prevent
inheritance during exec() calls (though this doesn't help with fork()
which is how shells spawn background processes).

Fixes issue 205 - failing unit tests.
darthrubik added 1 commit 2026-08-12 16:08:17 -05:00
The fcntl() calls for FD_CLOEXEC were removed in a previous commit but
the include statement was left behind. This removes the dead include.
darthrubik merged commit 34f317d38a into master 2026-08-12 16:08:30 -05:00
darthrubik deleted branch bugfix/hanging-background-processes 2026-08-12 16:08:30 -05:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: darthrubik/drharness#54