diff options
author | Jonas Faklkevik <jonas.falkevik@gmail.com> | 2011-05-02 20:10:05 +0200 |
---|---|---|
committer | Jonas Falkevik <jonas.falkevik@gmail.com> | 2011-05-02 20:10:05 +0200 |
commit | 1307af30ec3e2bfaeeca45a63fbc944791662226 (patch) | |
tree | 28cc619f87f3603b2528ef7f14e1eabeca1b9e9c /erts/etc/unix | |
parent | 0e752dde5e322373055c810386353e1d2cc61836 (diff) | |
download | otp-1307af30ec3e2bfaeeca45a63fbc944791662226.tar.gz otp-1307af30ec3e2bfaeeca45a63fbc944791662226.tar.bz2 otp-1307af30ec3e2bfaeeca45a63fbc944791662226.zip |
Teach run_erl RUN_ERL_DISABLE_FLOWCNTRL for disabling flow control
Flow control can cause unwanted behaviour of the beam process,
if accidentally hit Ctrl-S (instead of Ctrl-D to detach) the
entire beam may be blocked.
Fix this problem by making it possible to turn off flow
control by setting the environment variable RUN_ERL_DISABLE_FLOWCNTRL.
Diffstat (limited to 'erts/etc/unix')
-rw-r--r-- | erts/etc/unix/run_erl.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/erts/etc/unix/run_erl.c b/erts/etc/unix/run_erl.c index e97cc14fab..8db8e09bee 100644 --- a/erts/etc/unix/run_erl.c +++ b/erts/etc/unix/run_erl.c @@ -991,9 +991,7 @@ static int open_pty_master(char **ptyslave) static int open_pty_slave(char *name) { int sfd; -#ifdef DEBUG struct termios tty_rmode; -#endif if ((sfd = open(name, O_RDWR, 0)) < 0) { return -1; @@ -1019,6 +1017,25 @@ static int open_pty_slave(char *name) } #endif + if (getenv("RUN_ERL_DISABLE_FLOWCNTRL")) { + if (tcgetattr(sfd, &tty_rmode) < 0) { + fprintf(stderr, "Cannot get terminal's current mode\n"); + exit(-1); + } + + tty_rmode.c_iflag &= ~IXOFF; + if (tcsetattr(sfd, TCSANOW, &tty_rmode) < 0) { + fprintf(stderr, "Cannot disable terminal's flow control on input\n"); + exit(-1); + } + + tty_rmode.c_iflag &= ~IXON; + if (tcsetattr(sfd, TCSANOW, &tty_rmode) < 0) { + fprintf(stderr, "Cannot disable terminal's flow control on output\n"); + exit(-1); + } + } + #ifdef DEBUG if (tcgetattr(sfd, &tty_rmode) < 0) { fprintf(stderr, "Cannot get terminals current mode\n"); |