Browse Source

ending a ncurses proggy is not simple

phyto 4 months ago
parent
commit
4a033432bf
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      essai.c

+ 5
- 3
essai.c View File

@@ -126,7 +126,7 @@ fclose(fp);
126 126
 return 0;
127 127
 }
128 128
 /* --------------------------------------------------------------- */
129
-static void finish(int signal)
129
+static void finish(void)
130 130
 {
131 131
 endwin();       
132 132
 fprintf(stderr, "end of pid %d\n", getpid());
@@ -180,16 +180,18 @@ sleep(1);
180 180
 initscr();
181 181
 nonl();         cbreak();       noecho();
182 182
 keypad(stdscr, TRUE);           /* acces aux touches 'curseur' */
183
+atexit(finish);
184
+
183 185
 sprintf(ligne, " Demonstrator pid:%d %s ", getpid(), device);
184 186
 fond_ecran(ligne);
185 187
 
188
+
186 189
 traite_les_messages(serial_in, nbreloops, K);
187 190
 
188 191
 /*
189 192
  *      plop, on a fini, il faut restaurer la console
190 193
  */
191
-finish(0);
192
-
194
+finish();
193 195
 
194 196
 return 0;
195 197
 }

Loading…
Cancel
Save