SpartanJ / eepp

eepp is an open source cross-platform game and application development framework heavily focused on the development of rich graphical user interfaces.
https://eepp.ensoft.dev
MIT License
439 stars 39 forks source link

Child file descriptors not closed on join #84

Open mdales opened 3 days ago

mdales commented 3 days ago

Whilst debugging #83 I looked first to see if the pipe file descriptors were being closed, which isn't the case. However, the parent does leak file descriptors, as the parent side FDs are only closed on a call to subprocess_destroy, not in subprocess_join. This makes sense: on wait/join there may be some last data written to stdout/stderr by the child, so that still needs read.

Looking at the code I'd suggest the destructor for Process should call subprocess_destroy. I need to test that though, which is why this is an issue rather than a PR.

SpartanJ commented 2 days ago

Thanks for reporting it. You're right! I broke this when fixed SpartanJ/ecode#61 with these changes. I'm still not completely sure what it was the logic behind these changes. I pushed a change that will close the file descriptors and works on macOS (and should work fine on all posix OSes), but I still will need to verify I did not break anything on the Windows build since the fix that broke this was for a Windows specific problem.