Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

New pdftops does not correctly wait for child on cancel #2808

Closed

Description

@michaelrsweet

Version: 1.4-current
CUPS.org User: martin.pitt.canonical

Hello,

in http://www.cups.org/str.php?L2780 you fixed the EINTR problem I reported, thank you! However, your patch introduced a change in behaviour: when cancelling a job (and thus calling the signal handler, which sets job_canceled=1), the following "pdfwaitpid != pdfpid" matches, since wait() returned -1/EINTR, but due to job_canceled==1, the while loop was broken. This would then always be considered as a failure, i. e. pdftops would exit with 1.

When applying that patch (instead of mine), the test suite now fails on "11 errors instead of expected 9", on the following:

E [21/Apr/2008:16:57:40 +0000] PID 29175 (/tmp/cups-martin/bin/filter/pdftops) stopped with status 1!
E [21/Apr/2008:16:57:40 +0000] PID 29177 (/tmp/cups-martin/bin/filter/pstops) stopped with status 1!

There are two possibilities:

  • pdftops is actually meant to exit with 1 when a job is cancelled. Then the test cases need to be updated.
  • pdftops should succeed if a job is cancelled. Then something like the attached patch should help. (NB that I also added 'volatile', just for robustness; gcc seems to be clever enough to not optimize away the lookup in the while loop, though)

That helps to drop the error messages from 11 to 10, I still get

E [21/Apr/2008:17:13:22 +0000] PID 4457 (/tmp/cups-martin/bin/filter/pstops) stopped with status 1!

which I don't get if I unapply your patch in STR #2780 and just apply my proposed patch there. I do see that the idea of your patch is better, but ATM I seem to be too blind to spot the problem...

Thank you!

Activity

  1. michaelrsweet commented on Apr 21, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: martin.pitt.canonical

    Ah, with that updated patch it works for me again. Even if we cancel a job, it should still be properly cleaned up by wait()ing on it, instead of turning it into a zombie.

  2. michaelrsweet commented on Apr 21, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    The correct exit code on cancel should be "1", but we shouldn't be logging this as an error since we have asked for the job to be canceled. That is a separate issue I'm fixing now so that we get a clean run of tests.

    I've changed the bug summary to reflect the real issue.

  3. michaelrsweet commented on Apr 21, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Fixed in Subversion repository.

    Oh, and this is a dupe of STR #2806, which I had filed earlier... :)

  4. michaelrsweet commented on Apr 21, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    OK, not specifically a dupe then but a problem with the cancel of the child - I've updated the summary once again and attached a patch that will do what is required...

  5. michaelrsweet commented on Apr 21, 2008

    @michaelrsweet
    ContributorAuthor

    "str2808.patch":

    Index: pdftops.c

    --- pdftops.c (revision 7480)
    +++ pdftops.c (revision 7481)
    @@ -327,23 +327,21 @@
    * Parent comes here...
    */

    • while ((pdfwaitpid = wait(&pdfstatus)) < 0 && errno == EINTR)

    • while ((pdfwaitpid = wait(&pdfstatus)) != pdfpid && errno == EINTR)
      {
      /*

    • Wait until we get a valid process ID or the job is canceled...
      */

      if (job_canceled)

    • break;

    •  {
      
    •    kill(pdfpid, SIGTERM);
      
    • job_canceled = 0;

    •  }
      

      }

    • if (pdfwaitpid != pdfpid)

    • if (pdfstatus)
      {

    •  kill(pdfpid, SIGTERM);
      
    •  pdfstatus = 1;
      
    • }

    • else if (pdfstatus)

    • {
      if (WIFEXITED(pdfstatus))
      {
      pdfstatus = WEXITSTATUS(pdfstatus);

  6. added this to the Stable milestone on Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions