2022-10-22  Juan Manuel Guerrero <juan.guerrero@gmx.de>


	* src/open_filename.c [__DJGPP__]: Include required DJGPP specific
	headers.
	(WavpackOpenFileInput) [__DJGPP__]: For DJGPP, reenable SIGINT and
	SIGQUIT signals if stdin and/or stdout is connected to console and
	has been switched to binary mode.







diff -aprNU3 wavpack-5.5.0.orig/src/open_filename.c wavpack-5.5.0/src/open_filename.c
--- wavpack-5.5.0.orig/src/open_filename.c	2022-07-08 07:49:54 +0000
+++ wavpack-5.5.0/src/open_filename.c	2022-10-22 02:21:04 +0000
@@ -33,6 +33,12 @@
 #include <io.h>
 #endif
 
+#ifdef __DJGPP__
+# include <io.h>           /* declares setmode() */
+# include <unistd.h>       /* declares isatty() */
+# include <sys/exceptn.h>  /* declares __djgpp_set_ctrl_c() */
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 
@@ -246,6 +252,22 @@ WavpackContext *WavpackOpenFileInput (co
 #if defined(__OS2__)
         setmode (fileno (stdin), O_BINARY);
 #endif
+#if defined(__DJGPP__)
+        /* Putting stdin/stdout in binary mode if it is connected to
+           the console, would make it impossible for the user to
+           interrupt the program through Ctrl-C or Ctrl-Break.  */
+
+        /* This is DJGPP-specific.  By default, switching console
+           to binary mode disables SIGINT and SIGQUIT.  But we want
+           terminal reads to be interruptible.  */
+
+        {
+            int fd = fileno (stdin);
+            setmode (fd, O_BINARY);
+            if (isatty (fd))
+                __djgpp_set_ctrl_c (1);
+        }
+#endif
     }
     else if ((wv_id = fopen_func (infilename, file_mode)) == NULL) {
         if (error) strcpy (error, (flags & OPEN_EDIT_TAGS) ? "can't open file for editing" : "can't open file");
