rohanlele
Posts: 6
Joined: Fri Apr 27, 2018 3:58 am

Terminal window freezes after running an executable from the shell

Fri May 11, 2018 8:38 pm

Hi,
I am running an executable from home directory on the raspberry pi.

The executable is a compiled and linked C program involving the UART (ttyAMA0). The executable runs successfully and terminates.
Command used to start the executable: [email protected]: $./filename (filename is the name of the executable).

But the terminal window used to run the executable freezes i.e. I cannot see the characters typed into the terminal, but the commands are executed. This is undesirable behavior every time I try to run the code.

Please help.

Thanks,
Rohan

n67
Posts: 876
Joined: Mon Oct 30, 2017 4:55 pm

Re: Terminal window freezes after running an executable from the shell

Fri May 11, 2018 9:03 pm

It sounds like the program changes your TTY modes and then fails to reset them on exiting. This could happen because the program is exiting abnormally (i.e, via an uncaught signal). If this is the case, then you should be looking into figuring out what's wrong and fixing it.

Anyway, the usual fix for this is to type (blind, since you won't be able to see the characters):

stty sane^J

That is, you type "stty sane" and terminate with Ctrl/J, not Enter.

You might also try "reset" (and, for laughs, start with "man reset")

P.S. I've hit this problem and the usual workaround (not a fix) is to put the command into a shell script that contains:

funnyCommand_That_messes_up_the_TTY
stty sane

Then run that shell script instead of running the program directly.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

n67
Posts: 876
Joined: Mon Oct 30, 2017 4:55 pm

Re: Terminal window freezes after running an executable from the shell

Fri May 11, 2018 9:05 pm

Note, incidentally, that one nice thing about having tcsh as your shell, instead of sh or bash or whatever, is that tcsh always resets your tty modes before prompting for a command. So, this sort of thing cannot happen.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

Return to “General programming discussion”