diff options
author | Lukas Larsson <[email protected]> | 2016-08-31 11:11:27 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2016-09-02 09:51:55 +0200 |
commit | 7c5f497ab6f4b145554ee884e9fa0ec86246e9ee (patch) | |
tree | 70ed27668b160a44ff81cf7c6dca96ecedd58373 /erts/emulator/sys/unix/sys.c | |
parent | bba0f5924fa9478d41903331a3285f117c112731 (diff) | |
download | otp-7c5f497ab6f4b145554ee884e9fa0ec86246e9ee.tar.gz otp-7c5f497ab6f4b145554ee884e9fa0ec86246e9ee.tar.bz2 otp-7c5f497ab6f4b145554ee884e9fa0ec86246e9ee.zip |
erts: Fix child setup signal hander bug
When running the signal handler, the errno has to be restored
to its original value, otherwise code running in the same thread
may misbehave.
Diffstat (limited to 'erts/emulator/sys/unix/sys.c')
-rw-r--r-- | erts/emulator/sys/unix/sys.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c index 6fb86f6dda..089efec3e8 100644 --- a/erts/emulator/sys/unix/sys.c +++ b/erts/emulator/sys/unix/sys.c @@ -715,11 +715,13 @@ static RETSIGTYPE suspend_signal(void) static RETSIGTYPE suspend_signal(int signum) #endif { - int res; - int buf[1]; - do { - res = read(sig_suspend_fds[0], buf, sizeof(int)); - } while (res < 0 && errno == EINTR); + int res, buf[1], __errno = errno; + do { + res = read(sig_suspend_fds[0], buf, sizeof(int)); + } while (res < 0 && errno == EINTR); + + /* restore previous errno in case read changed it */ + errno = __errno; } #endif /* #ifdef ERTS_SYS_SUSPEND_SIGNAL */ |