Skip to content

Commit

Permalink
On h.quit() terminal settings are same as when neuron.hoc was importe…
Browse files Browse the repository at this point in the history
…d. (#3259)


* Print tcgetatt/tcsetattr error messages only if STDIN is a tty.
  • Loading branch information
nrnhines authored Dec 3, 2024
1 parent 95b14c9 commit 6dfdc4a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/nrnpython/inithoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ static int have_opt(const char* arg) {
static struct termios original_termios;

static void save_original_terminal_settings() {
if (tcgetattr(STDIN_FILENO, &original_termios) == -1) {
if (tcgetattr(STDIN_FILENO, &original_termios) == -1 && isatty(STDIN_FILENO)) {
std::cerr << "Error getting original terminal attributes\n";
}
}

static void restore_original_terminal_settings() {
if (tcsetattr(STDIN_FILENO, TCSANOW, &original_termios) == -1) {
if (tcsetattr(STDIN_FILENO, TCSANOW, &original_termios) == -1 && isatty(STDIN_FILENO)) {
std::cerr << "Error restoring terminal attributes\n";
}
}
Expand Down

0 comments on commit 6dfdc4a

Please sign in to comment.