2022-04-20  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* cdjpeg.c [__DJGPP__]: Include <sys/exceptn.h> for __djgpp_set_ctrl_c
	declaration and <unistd.h> for isatty declaration.
	(read_stdin) [__DJGPP__]: Reenable SIGINT and SIGQUIT if stdin is
	connected to console and has been switched to binary mode.
	(write_stdout) [__DJGPP__]: Reenable SIGINT and SIGQUIT if stdout is
	connected to console and has been switched to binary mode.

	* rdjpgcom.c [__DJGPP__]: Include <sys/exceptn.h> for __djgpp_set_ctrl_c
	declaration and <unistd.h> for isatty declaration.
	(main) [__DJGPP__]: Reenable SIGINT and SIGQUIT if stdin is connected to
	console and has been switched to binary mode.

	* wrjpgcom.c [__DJGPP__]: Include <sys/exceptn.h> for __djgpp_set_ctrl_c
	declaration and <unistd.h> for isatty declaration.
	(main) [__DJGPP__]: Reenable SIGINT and SIGQUIT if stdin is connected
	to console and has been switched to binary mode.
	[__DJGPP__]: Reenable SIGINT and SIGQUIT if stdout is connected to
	console and has been switched to binary mode.





diff -aprNU5 jpeg-9e.orig/cdjpeg.c jpeg-9e/cdjpeg.c
--- jpeg-9e.orig/cdjpeg.c	1997-09-07 15:51:36 +0000
+++ jpeg-9e/cdjpeg.c	2022-04-20 19:09:28 +0000
@@ -16,10 +16,14 @@
 #endif
 #ifdef USE_SETMODE
 #include <fcntl.h>		/* to declare setmode()'s parameter macros */
 /* If you have setmode() but not <io.h>, just delete this line: */
 #include <io.h>			/* to declare setmode() */
+#ifdef __DJGPP__
+#include <unistd.h>		/* to declare isatty() */
+#include <sys/exceptn.h>	/* to declare __djgpp_set_ctrl_c() */
+#endif
 #endif
 
 
 /*
  * Signal catcher to ensure that temporary files are removed before aborting.
@@ -157,10 +161,18 @@ read_stdin (void)
   if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) {
     fprintf(stderr, "Cannot reopen stdin\n");
     exit(EXIT_FAILURE);
   }
 #endif
+#ifdef __DJGPP__
+   /* This is DJGPP-specific.  By default, switching console
+      to binary mode disables SIGINT and SIGQUIT.  But it
+      is preferable to have terminal reads and writes to
+      be interruptible.  */
+  if (isatty(fileno(stdin)))
+    __djgpp_set_ctrl_c(1);
+#endif
   return input_file;
 }
 
 
 GLOBAL(FILE *)
@@ -175,7 +187,15 @@ write_stdout (void)
   if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {
     fprintf(stderr, "Cannot reopen stdout\n");
     exit(EXIT_FAILURE);
   }
 #endif
+#ifdef __DJGPP__
+   /* This is DJGPP-specific.  By default, switching console
+      to binary mode disables SIGINT and SIGQUIT.  But it
+      is preferable to have terminal reads and writes to
+      be interruptible.  */
+  if (isatty(fileno(stdout)))
+    __djgpp_set_ctrl_c(1);
+#endif
   return output_file;
 }
diff -aprNU5 jpeg-9e.orig/rdjpgcom.c jpeg-9e/rdjpgcom.c
--- jpeg-9e.orig/rdjpgcom.c	2009-04-02 23:30:12 +0000
+++ jpeg-9e/rdjpgcom.c	2022-04-20 19:09:28 +0000
@@ -21,10 +21,14 @@
 #include <ctype.h>		/* to declare isupper(), tolower() */
 #ifdef USE_SETMODE
 #include <fcntl.h>		/* to declare setmode()'s parameter macros */
 /* If you have setmode() but not <io.h>, just delete this line: */
 #include <io.h>			/* to declare setmode() */
+#ifdef __DJGPP__
+#include <unistd.h>		/* to declare isatty() */
+#include <sys/exceptn.h>	/* to declare __djgpp_set_ctrl_c() */
+#endif
 #endif
 
 #ifdef USE_CCOMMAND		/* command-line reader for Macintosh */
 #ifdef __MWERKS__
 #include <SIOUX.h>              /* Metrowerks needs this */
@@ -502,10 +506,18 @@ main (int argc, char **argv)
       exit(EXIT_FAILURE);
     }
 #else
     infile = stdin;
 #endif
+#ifdef __DJGPP__
+   /* This is DJGPP-specific.  By default, switching console
+      to binary mode disables SIGINT and SIGQUIT.  But it
+      is preferable to have terminal reads and writes to
+      be interruptible.  */
+    if (isatty(fileno(stdin)))
+      __djgpp_set_ctrl_c(1);
+#endif
   }
 
   /* Scan the JPEG headers. */
   (void) scan_JPEG_header(verbose, raw);
 
diff -aprNU5 jpeg-9e.orig/wrjpgcom.c jpeg-9e/wrjpgcom.c
--- jpeg-9e.orig/wrjpgcom.c	2017-09-15 14:20:24 +0000
+++ jpeg-9e/wrjpgcom.c	2022-04-20 19:09:28 +0000
@@ -21,10 +21,14 @@ extern void * malloc ();
 #include <ctype.h>		/* to declare isupper(), tolower() */
 #ifdef USE_SETMODE
 #include <fcntl.h>		/* to declare setmode()'s parameter macros */
 /* If you have setmode() but not <io.h>, just delete this line: */
 #include <io.h>			/* to declare setmode() */
+#ifdef __DJGPP__
+#include <unistd.h>		/* to declare isatty() */
+#include <sys/exceptn.h>	/* to declare __djgpp_set_ctrl_c() */
+#endif
 #endif
 
 #ifdef USE_CCOMMAND		/* command-line reader for Macintosh */
 #ifdef __MWERKS__
 #include <SIOUX.h>              /* Metrowerks needs this */
@@ -513,10 +517,18 @@ main (int argc, char **argv)
       exit(EXIT_FAILURE);
     }
 #else
     infile = stdin;
 #endif
+#ifdef __DJGPP__
+   /* This is DJGPP-specific.  By default, switching console
+      to binary mode disables SIGINT and SIGQUIT.  But it
+      is preferable to have terminal reads and writes to
+      be interruptible.  */
+    if (isatty(fileno(stdin)))
+      __djgpp_set_ctrl_c(1);
+#endif
   }
 
   /* Open the output file. */
 #ifdef TWO_FILE_COMMANDLINE
   /* Must have explicit output file name */
@@ -545,10 +557,18 @@ main (int argc, char **argv)
     exit(EXIT_FAILURE);
   }
 #else
   outfile = stdout;
 #endif
+#ifdef __DJGPP__
+   /* This is DJGPP-specific.  By default, switching console
+      to binary mode disables SIGINT and SIGQUIT.  But it
+      is preferable to have terminal reads and writes to
+      be interruptible.  */
+  if (isatty(fileno(stdout)))
+    __djgpp_set_ctrl_c(1);
+#endif
 #endif /* TWO_FILE_COMMANDLINE */
 
   /* Collect comment text from comment_file or stdin, if necessary */
   if (comment_arg == NULL) {
     FILE * src_file;
