]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/reset_cmd.c
ncurses 6.3
[ncurses.git] / progs / reset_cmd.c
index 5e517cc74e9e0b656a0daeed3329bf7d3729aa24..eff3af729e6090c75ac0737fb139aa482c80d89a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
  * Copyright 2016,2017 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
 #endif
 
 #if NEED_PTEM_H
-/* they neglected to define struct winsize in termios.h -- it's only
+/* they neglected to define struct winsize in termios.h -- it is only
    in termio.h */
 #include <sys/stream.h>
 #include <sys/ptem.h>
 #endif
 
-MODULE_ID("$Id: reset_cmd.c,v 1.24 2020/11/21 22:11:10 tom Exp $")
+MODULE_ID("$Id: reset_cmd.c,v 1.28 2021/10/02 18:08:44 tom Exp $")
 
 /*
  * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
@@ -80,7 +80,7 @@ static FILE *my_file;
 static bool use_reset = FALSE; /* invoked as reset */
 static bool use_init = FALSE;  /* invoked as init */
 
-static void
+static GCC_NORETURN void
 failed(const char *msg)
 {
     int code = errno;
@@ -102,7 +102,7 @@ cat_file(char *file)
     bool sent = FALSE;
 
     if (file != 0) {
-       if ((fp = fopen(file, "r")) == 0)
+       if ((fp = safe_fopen(file, "r")) == 0)
            failed(file);
 
        while ((nr = fread(buf, sizeof(char), sizeof(buf), fp)) != 0) {
@@ -193,7 +193,7 @@ out_char(int c)
  * a child program dies in raw mode.
  */
 void
-reset_tty_settings(int fd, TTY * tty_settings)
+reset_tty_settings(int fd, TTY * tty_settings, int noset)
 {
     GET_TTY(fd, tty_settings);
 
@@ -329,7 +329,9 @@ reset_tty_settings(int fd, TTY * tty_settings)
        );
 #endif
 
-    SET_TTY(fd, tty_settings);
+    if (!noset) {
+       SET_TTY(fd, tty_settings);
+    }
 }
 
 /*