Sfoglia il codice sorgente

Fix broken pipe bug after fullscreen Graph apps

Arthur Yefimov 3 anni fa
parent
commit
227d825433
1 ha cambiato i file con 12 aggiunte e 0 eliminazioni
  1. 12 0
      src/term/term_linux.c

+ 12 - 0
src/term/term_linux.c

@@ -33,6 +33,12 @@ int StartProcessIn(char *process, char *dir) {
   char cmd[600];
   char cmd[600];
   int success = 0;
   int success = 0;
   int i, j;
   int i, j;
+
+      // Ignore SIGPIPE in case of a write to a broken pipe
+      if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
+        puts("Could not ignore SIGPIPE signal.");
+      }
+
   if ((pipe(p) == -1) || (pipe(q) == -1)) {
   if ((pipe(p) == -1) || (pipe(q) == -1)) {
     perror("StartProcess: Could not create pipes.");
     perror("StartProcess: Could not create pipes.");
   } else {
   } else {
@@ -69,6 +75,12 @@ int StartProcessIn(char *process, char *dir) {
         puts("Could not run program.");
         puts("Could not run program.");
         exit(0);
         exit(0);
       }
       }
+      /*
+      // Ignore SIGPIPE in case of a write to a broken pipe
+      if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
+        puts("Could not ignore SIGPIPE signal.");
+      }
+      */
     } else { // Parent process
     } else { // Parent process
       close(q[0]);
       close(q[0]);
       close(p[1]);
       close(p[1]);