Skip to content

Commit

Permalink
Check the process status before waiting, it appears to be edge trigge…
Browse files Browse the repository at this point in the history
…red. (#125)
  • Loading branch information
ioquatix authored Nov 24, 2024
1 parent 44a155c commit 073fa6a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ext/io/event/selector/epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,13 @@ VALUE IO_Event_Selector_EPoll_process_wait(VALUE self, VALUE fiber, VALUE _pid,

rb_update_max_fd(descriptor);

// `pidfd_open` (above) may be edge triggered, so we need to check if the process is already exited, and if so, return immediately, otherwise we will block indefinitely.
VALUE status = IO_Event_Selector_process_status_wait(pid, flags);
if (status != Qnil) {
close(descriptor);
return status;
}

struct IO_Event_Selector_EPoll_Waiting waiting = {
.list = {.type = &IO_Event_Selector_EPoll_process_wait_list_type},
.fiber = fiber,
Expand Down

0 comments on commit 073fa6a

Please sign in to comment.