Skip to content

Commit

Permalink
unix: retry ioctl(TIOCGWINSZ) on EINTR
Browse files Browse the repository at this point in the history
Some platforms (notably Solaris) can fail in this ioctl() if interrupted
by a signal.  Retry the system call when that happens.

Fixes: nodejs/node#5737
  • Loading branch information
bnoordhuis committed Mar 20, 2016
1 parent df96163 commit aabcfc7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/unix/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,13 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {

int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
struct winsize ws;
int err;

do
err = ioctl(uv__stream_fd(tty), TIOCGWINSZ, &ws);
while (err == -1 && errno == EINTR);

if (ioctl(uv__stream_fd(tty), TIOCGWINSZ, &ws))
if (err == -1)
return -errno;

*width = ws.ws_col;
Expand Down

0 comments on commit aabcfc7

Please sign in to comment.