Skip to content

Commit

Permalink
Fix transferring error exit status from children in ghostscript and m…
Browse files Browse the repository at this point in the history
…updf filter functions (Issue #76) (#77)

ghostcript and mupdf filter functions did not transfer error exit code
from a child and rewrote the code by successful exit code from the other
child.

Fixes #76
  • Loading branch information
zdohnal authored Jan 20, 2025
1 parent 0d98684 commit 0158844
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cupsfilters/ghostscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,13 @@ gs_spawn (const char *filename,
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterGhostscript: Input data feed completed");

//
// Initialize to exit status 'Success' first - any error exit status
// from children process will rewrite it, and wait for children...
//

status = 0;

while (gspid > 0 || errpid > 0)
{
if ((pid = wait(&wstatus)) < 0)
Expand Down Expand Up @@ -744,7 +751,6 @@ gs_spawn (const char *filename,
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterGhostscript: %s (PID %d) exited with no errors.",
(pid == gspid ? "Ghostscript" : "Logging"), pid);
status = 0;
}
if (pid == gspid)
gspid = -1;
Expand Down
8 changes: 7 additions & 1 deletion cupsfilters/mupdftopwg.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,13 @@ mutool_spawn(const char *filename,

close(errfds[0]);

//
// Initialize to exit status 'Success' first - any error exit status
// from children process will rewrite it, and wait for children..
//

status = 0;

while (mutoolpid > 0 || errpid > 0)
{
if ((pid = wait(&wstatus)) < 0)
Expand Down Expand Up @@ -389,7 +396,6 @@ mutool_spawn(const char *filename,
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterMuPDFToPWG: %s (PID %d) exited with no errors.",
(pid == mutoolpid ? "mutool" : "Logging"), pid);
status = 0;
}
if (pid == mutoolpid)
mutoolpid = -1;
Expand Down

0 comments on commit 0158844

Please sign in to comment.