Commits

Evan Gates committed 97bc82e

use STDIN not 0

  • Participants
  • Parent commits f611bf2

Comments (0)

Files changed (1)

 #define cursor_fwd(n) printf("\033[%dC", MAX(1, (n)))
 #define cursor_org()  printf("\033[1;1H")
 
+struct sig {
+	int sig;
+	char *name;
+	void (*func)(int);
+};
+
 void erase_usr(void);
 void my_write(int fd, const char *buf, size_t count);
 void print_usr(void);
 void term_set(int unused);
 void usage(void);
 
-struct sig {
-	int sig;
-	char *name;
-	void (*func)(int);
-};
-
 struct sig sig_table[] = {
 	{SIGINT,  "SIGINT" , quit    },
 	{SIGTERM, "SIGTERM", quit    },
 
 void term_set(int unused)
 {
-	tcsetattr(0, TCSANOW, &set);
+	tcsetattr(STDIN, TCSANOW, &set);
 	print_usr();
 }
 
 void quit(int sig)
 {
-	tcsetattr(0, TCSANOW, &dfl);
+	tcsetattr(STDIN, TCSANOW, &dfl);
 	exit(sig);
 }
 
 
 void stop(int unused)
 {
-	tcsetattr(0, TCSANOW, &dfl);
+	tcsetattr(STDIN, TCSANOW, &dfl);
 	kill(-getpid(), SIGSTOP);
 }
 
 	if (i >= argc)
 		usage();
 
-	tcgetattr(0, &dfl);
+	tcgetattr(STDIN, &dfl);
 	memcpy(&set, &dfl, sizeof(set));
 	set.c_lflag &= ~ECHO;
 
 	set.c_lflag    &= ~(ICANON | ECHO);
 	set.c_cc[VMIN ] = 1;
 	set.c_cc[VTIME] = 0;
-	tcsetattr(0, TCSANOW, &set);
+	tcsetattr(STDIN, TCSANOW, &set);
 
 	for (i = 0; sig_table[i].sig; i++)
 		if (signal(sig_table[i].sig, sig_table[i].func) == SIG_ERR)