Errno::EINTR: Interrupted system call on console#echo=

$B!!$5$5$@$G$9!#(B

$B!!8=<BE*$K$O$[$\L5$5$=$&$J$s$G$9$,!"(Bsetattr()$B!J(Btcsetattr()$B!K(B
$B$,(B EINTR $B$r(B
$BJV$92DG=@-$,!"L5$/$O$J$$$h$&$G$9!#$I$&$$$&%7%A%e%(!<%7%g%s$@$m$&!#(B

EINTR $B$rL5M}LpM}:n$C$F8+$D$1$^$7$?!#(B

Index: console.c

— console.c (revision 29985)
+++ console.c (working copy)
@@ -323,7 +323,11 @@
set_echo(&t);
else
set_noecho(&t);

  • if (!setattr(fd, &t)) rb_sys_fail(0);
  • retry:
  • if (!setattr(fd, &t)) {
  • if (errno == EINTR) goto retry;
  • rb_sys_fail(0);
  • }
    return io;
    }

(2010/12/01 23:13), SASADA Koichi wrote:

$B!!8=<BE*$K$O$[$\L5$5$=$&$J$s$G$9$,!"(Bsetattr()$B!J(Btcsetattr()$B!K(B $B$,(B
EINTR $B$r(B
$BJV$92DG=@-$,!"L5$/$O$J$$$h$&$G$9!#$I$&$$$&%7%A%e%(!<%7%g%s$@$m$&!#(B

$B!!$3$&$+$J!#(B

Index: ext/io/console/console.c

— ext/io/console/console.c (revision 29985)
+++ ext/io/console/console.c (working copy)
@@ -26,7 +26,16 @@
#if defined HAVE_TERMIOS_H

include <termios.h>

typedef struct termios conmode;
-# define setattr(fd, t) (tcsetattr(fd, TCSAFLUSH, t) == 0)
+
+static int
+setattr(int fd, conmode *t)
+{

  • int r;
  • retry:
  • r = tcsetattr(fd, TCSAFLUSH, t);
  • if (r != 0 && errno == EINTR) goto retry;
  • return r == 0;
    +}

define getattr(fd, t) (tcgetattr(fd, t) == 0)

#elif defined HAVE_TERMIO_H

include <termio.h>