Index: pdftops.c =================================================================== --- pdftops.c (revision 7441) +++ pdftops.c (working copy) @@ -28,6 +28,7 @@ #include #include #include +#include /* @@ -38,6 +39,13 @@ /* + * Local globals... + */ + +static int job_canceled = 0; + + +/* * 'main()' - Main entry for filter... */ @@ -57,6 +65,7 @@ ppd_file_t *ppd; /* PPD file */ ppd_size_t *size; /* Current page size */ int pdfpid, /* Process ID for pdftops */ + pdfwaitpid, /* Process ID from wait() */ pdfstatus, /* Status from pdftops */ pdfargc; /* Number of args for pdftops */ char *pdfargv[100], /* Arguments for pdftops */ @@ -261,8 +270,18 @@ * Parent comes here... */ - if (wait(&pdfstatus) != pdfpid) + while ((pdfwaitpid = wait(&pdfstatus)) < 0 && errno == EINTR) { + /* + * Wait until we get a valid process ID or the job is canceled... + */ + + if (job_canceled) + break; + } + + if (pdfwaitpid != pdfpid) + { kill(pdfpid, SIGTERM); pdfstatus = 1; } @@ -270,18 +289,18 @@ { if (WIFEXITED(pdfstatus)) { - pdfstatus = WEXITSTATUS(pdfstatus); + pdfstatus = WEXITSTATUS(pdfstatus); - _cupsLangPrintf(stderr, - _("ERROR: pdftops filter exited with status %d!\n"), + _cupsLangPrintf(stderr, + _("ERROR: pdftops filter exited with status %d!\n"), pdfstatus); } else { - pdfstatus = WTERMSIG(pdfstatus); + pdfstatus = WTERMSIG(pdfstatus); - _cupsLangPrintf(stderr, - _("ERROR: pdftops filter crashed on signal %d!\n"), + _cupsLangPrintf(stderr, + _("ERROR: pdftops filter crashed on signal %d!\n"), pdfstatus); } } @@ -306,6 +325,8 @@ cancel_job(int sig) /* I - Signal number (unused) */ { (void)sig; + + job_canceled = 1; }