pashapm / lanterna

Automatically exported from code.google.com/p/lanterna
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Terminal control codes not restored on Solaris #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The classic terminal control codes ctrl+c, ctrl+d, etc, are not working after 
exiting private mode, when running on Solaris.

Original issue reported on code.google.com by mab...@gmail.com on 19 Nov 2012 at 1:03

GoogleCodeExporter commented 9 years ago
After playing around with my sample program, I believe I identified why the 
restore commands do not work. It seems that the "restore character" needs to be 
wrapped with single quotes, otherwise stty will silently ignore.

For instance, for the moment, the following line is trying to restore ctrl c 
that way:
 exec("/bin/sh", "-c", "/bin/stty intr ^C < /dev/tty");
It should actually be written this way:
 exec("/bin/sh", "-c", "/bin/stty intr '^C' < /dev/tty");

I succesfully tested the above change on Solaris 10 x86.

Actually, when you issue the following commands, this shows what error happens:
-bash-3.00$ /bin/sh -c "/bin/stty intr ^C < /dev/tty"
/bin/sh: C: not found
-bash-3.00$ stty: : I/O error

-bash-3.00$ /bin/sh -c "/bin/stty intr '^C' < /dev/tty"
-bash-3.00

Escaping with single quotes is required because of passing the command to 
/bin/sh -c.

Original comment by jli...@gmail.com on 3 Jan 2013 at 4:00

GoogleCodeExporter commented 9 years ago
How about using the -g option of stty to save and restore the options ? I just 
came across this one when reading the man page:
     The -g flag is designed to facilitate the saving and restor-
     ing  of  terminal state from the shell level. For example, a
     program may:

     saveterm="$(stty -g)"      # save terminal state
     stty (new settings)        # set new state
     ...           # ...
     stty $saveterm                # restore terminal state

     Since the -a format is so loosely  specified,  scripts  that
     save and restore terminal settings should use the -g option.

Original comment by jli...@gmail.com on 3 Jan 2013 at 4:00

GoogleCodeExporter commented 9 years ago
Fixed in Issue 58

Original comment by mab...@gmail.com on 4 Jan 2013 at 2:00

GoogleCodeExporter commented 9 years ago

Original comment by mab...@gmail.com on 4 Jan 2013 at 2:01