]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: In pdftops() simplify feeding data into post-processing
authorTill Kamppeter <till.kamppeter@gmail.com>
Thu, 25 Nov 2021 15:57:12 +0000 (16:57 +0100)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 25 Nov 2021 15:57:12 +0000 (16:57 +0100)
In post-processing we stop assigning the file descriptorof the input
pipe to stdin and then read the data from stdin but instead, read the
data directly from stdin.

Without this improvement in some cases, especially when we do not have
a PPD file, we are not able to get the output data of the previous
step (Poppler's pdftops or Ghostscript to turn PDF to PostScript, and
the really strange is that this only happens when we call pdftops()
from the universal() filter function).

cupsfilters/pdftops.c

index cee1095ea0fc17a1d0f640466d51a6b05d7ab635..1882d54f1b99497aae62c1c6618a0c917b7c0884 100644 (file)
@@ -1252,8 +1252,6 @@ pdftops(int inputfd,         /* I - File descriptor input stream */
       * Child comes here...
       */
 
-      dup2(post_proc_pipe[0], 0);
-      close(post_proc_pipe[0]);
       close(post_proc_pipe[1]);
       if (ppd)
       {
@@ -1264,7 +1262,7 @@ pdftops(int inputfd,         /* I - File descriptor input stream */
       else
        dup2(outputfd, 1);
 
-      fp = cupsFileStdin();
+      fp = cupsFileOpenFd(post_proc_pipe[0], "r");
 
       if (renderer == ACROREAD)
       {
@@ -1579,6 +1577,7 @@ pdftops(int inputfd,         /* I - File descriptor input stream */
            fwrite(buffer, 1, bytes, stdout);
        }
       }
+      close(post_proc_pipe[0]);
 
       exit(0);
     }