mirror of
https://github.com/reactos/CMake.git
synced 2024-12-02 00:26:18 +00:00
libuv: unix: restart syscalls interrupted by our signal handler
BSD `signal(2)` semantics make some system calls (e.g. for `write`) restartable when interrupted by a signal handler. Use `SA_RESTART` to enable these semantics everywhere that supports them. This is required by C++ stream libraries that interpret `EINTR` as any other error, set `badbit`, and stop writing. I've observed this with `libstdc++` during a `std::cout.flush()` call interrupted by `SIGCHLD`.
This commit is contained in:
parent
f7f34a46e6
commit
4ffb0f8b45
@ -28,6 +28,9 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef SA_RESTART
|
||||
# define SA_RESTART 0
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uv_signal_t* handle;
|
||||
@ -216,7 +219,9 @@ static int uv__signal_register_handler(int signum, int oneshot) {
|
||||
if (sigfillset(&sa.sa_mask))
|
||||
abort();
|
||||
sa.sa_handler = uv__signal_handler;
|
||||
sa.sa_flags = oneshot ? SA_RESETHAND : 0;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
if (oneshot)
|
||||
sa.sa_flags |= SA_RESETHAND;
|
||||
|
||||
/* XXX save old action so we can restore it later on? */
|
||||
if (sigaction(signum, &sa, NULL))
|
||||
|
Loading…
Reference in New Issue
Block a user