Skip to content

Commit 073fa6a

Browse files
authored
Check the process status before waiting, it appears to be edge triggered. (#125)
1 parent 44a155c commit 073fa6a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/io/event/selector/epoll.c

+7
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,13 @@ VALUE IO_Event_Selector_EPoll_process_wait(VALUE self, VALUE fiber, VALUE _pid,
504504

505505
rb_update_max_fd(descriptor);
506506

507+
// `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.
508+
VALUE status = IO_Event_Selector_process_status_wait(pid, flags);
509+
if (status != Qnil) {
510+
close(descriptor);
511+
return status;
512+
}
513+
507514
struct IO_Event_Selector_EPoll_Waiting waiting = {
508515
.list = {.type = &IO_Event_Selector_EPoll_process_wait_list_type},
509516
.fiber = fiber,

0 commit comments

Comments
 (0)