diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2015-03-11 15:42:20 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2015-03-11 16:45:50 +0100 |
commit | 1df46fe47869244db44e90d2ced5685a4c921775 (patch) | |
tree | 7bbb54b3e5e14fc3dbde55dedba63a2a15ae3323 /src/unix/tty.c | |
parent | 25d4abbabb37bf450af098db551005bf028a2c73 (diff) | |
download | libuv-1df46fe47869244db44e90d2ced5685a4c921775.tar.gz libuv-1df46fe47869244db44e90d2ced5685a4c921775.zip |
unix: don't clobber errno in uv_tty_reset_mode()
uv_tty_reset_mode() is designed to be async signal-safe and is therefore
not allowed to clobber errno.
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Diffstat (limited to 'src/unix/tty.c')
-rw-r--r-- | src/unix/tty.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/unix/tty.c b/src/unix/tty.c index b1782df9..9038d85a 100644 --- a/src/unix/tty.c +++ b/src/unix/tty.c @@ -237,8 +237,10 @@ uv_handle_type uv_guess_handle(uv_file file) { * critical section when the signal was raised. */ int uv_tty_reset_mode(void) { + int saved_errno; int err; + saved_errno = errno; if (!uv_spinlock_trylock(&termios_spinlock)) return -EBUSY; /* In uv_tty_set_mode(). */ @@ -248,5 +250,7 @@ int uv_tty_reset_mode(void) { err = -errno; uv_spinlock_unlock(&termios_spinlock); + errno = saved_errno; + return err; } |