r-lib/processx

errno is modified in signal handlers

buchgr opened this issue · 1 comments

Using thread sanitizer I found that the signal handler for SIGCHLD processx__sigchld_callback

wp = waitpid(ptr->pid, &wstat, WNOHANG);

may modify errno. The fix is to save errno when entering and restoring it when exiting the signal handler, like in processx.c

saved_errno = errno;

I am happy to send a PR, but it's unclear to me yet on how to best write an automated test for it.

Thanks! A PR is welcome. No need to test for it in the PR, but a good test would be to run thread sanitizer on GHA.