aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2011-05-06 15:10:50 +0200
committerHenrik Nord <[email protected]>2011-05-06 15:11:02 +0200
commit67992620807364ae8a256e63d4804b81afa2c379 (patch)
tree81533bcec7c9b1e3ddb37bc72b138898642c1d8a
parent6fb4aec04d38bf6b5609b544981c9cebc2d1c89a (diff)
parent1307af30ec3e2bfaeeca45a63fbc944791662226 (diff)
downloadotp-67992620807364ae8a256e63d4804b81afa2c379.tar.gz
otp-67992620807364ae8a256e63d4804b81afa2c379.tar.bz2
otp-67992620807364ae8a256e63d4804b81afa2c379.zip
Merge branch 'jf/run_erl-disable-flow-control' into dev
* jf/run_erl-disable-flow-control: Teach run_erl RUN_ERL_DISABLE_FLOWCNTRL for disabling flow control OTP-9270
-rw-r--r--erts/doc/src/run_erl.xml8
-rw-r--r--erts/etc/unix/run_erl.c21
2 files changed, 27 insertions, 2 deletions
diff --git a/erts/doc/src/run_erl.xml b/erts/doc/src/run_erl.xml
index 7bf7f559c5..da08859c7b 100644
--- a/erts/doc/src/run_erl.xml
+++ b/erts/doc/src/run_erl.xml
@@ -144,6 +144,14 @@
<item>The size (in bytes) of a log file before switching to a
new log file. Default is 100000, minimum is 1000 and maximum is
approximately 2^30.</item>
+ <tag>RUN_ERL_DISABLE_FLOWCNTRL</tag>
+ <item>If defined, disables input and output flow control for the pty opend by run_erl.
+ Useful if you want to remove any risk of accidentally blocking the flow control
+ by hit Ctrl-S (instead of Ctrl-D to detach).
+ Which may result in blocking of the entire beam process
+ and in the case of running heart as supervisor
+ even the heart process will be blocked when writing log message to terminal.
+ Leaving the heart process unable to do its work.</item>
</taglist>
</section>
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");