repo: music
action: commit
revision: 
path_from: 
revision_from: 2d4ea557f7caaac08c2ffb5afb725a4233a21deb:
path_to: 
revision_to: 
git.thebackupbox.net
music
git clone git://git.thebackupbox.net/music
commit 2d4ea557f7caaac08c2ffb5afb725a4233a21deb
Author: epoch 
Date:   Sun Jun 7 08:23:00 2020 -0500

    sighup to skip to the end of of stdin in qargs.c

diff --git a/qargs.c b/qargs.c
index 5dd867fe3689a8590aad20c77fa37d05906ca9af..
index ..3e2ae79e50f6efd9c9564c5d402c1a06d5bd3031 100644
--- a/qargs.c
+++ b/qargs.c
@@ -1,4 +1,5 @@
 #define _POSIX_C_SOURCE 1
+#include 
 #include 
 #include 
 #include 
@@ -26,6 +27,19 @@ void sig_handler(int sig) {
       else fprintf(stderr,"shit. pid is %d\n",pid);
       direction=DIR_NEXT;
       break;
+    case SIGHUP:
+      if(fseek(stdin,0,SEEK_END) == -1) {
+        int oldfl;
+        oldfl=fcntl(fileno(stdin),F_GETFL);
+        if(oldfl == -1) {
+          fprintf(stderr,"F_GETFL failed for some derpy reason.\n");
+          break;
+        }
+        fcntl(fileno(stdin),F_SETFL,O_NONBLOCK);
+        while(fgetc(stdin) != -1);//this only works if non-blocking? :/
+        fcntl(fileno(stdin),F_SETFL,oldfl);
+        clearerr(stdin);
+      }
     default:
       //should NOT happen.
       break;
@@ -48,6 +62,7 @@ int main(int argc,char *argv[]) {
   while(1) {//I should come up with a better condition for the main loop
     signal(SIGUSR1,sig_handler);
     signal(SIGUSR2,sig_handler);
+    signal(SIGHUP,sig_handler);
     if(index == lines_read) {
       if(fgets(line[index % LINES],sizeof(line[index % LINES])-1,stdin) == 0) {
         fprintf(stderr,"Reached EOF on stdin.\n");

-----END OF PAGE-----