[cups.bugs] [HIGH] STR #1675: Canceling a job with USB back end results in ungraceful termination

Robert Krawitz rlk at alum.mit.edu
Wed May 10 17:43:44 PDT 2006


[STR New]

If the USB back end is used, and the user attempts to cancel a job, the job
will not terminate cleanly.  This is because the usb back end does not
ignore SIGTERM, as it is supposed to if it's taking input from stdin.  The
back end is supposed to ignore SIGTERM to allow upstream drivers to
cleanly close off the data stream.

This is due to a coding error in usb-unix.c:

  if (fp)  <<<<<<=======
  {
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
    sigset(SIGTERM, SIG_IGN);
#elif defined(HAVE_SIGACTION)
    memset(&action, 0, sizeof(action));

    sigemptyset(&action.sa_mask);
    action.sa_handler = SIG_IGN;
    sigaction(SIGTERM, &action, NULL);
#else
    signal(SIGTERM, SIG_IGN);
#endif /* HAVE_SIGSET */
  }

The problem here is that 'fp' is passed in as zero if the back end is
printing from stdin and non-zero (a real file descriptor, presumably other
than stdin) otherwise.  The effect is that it ignores SIGTERM if the user
is trying to print a file (precisely when it should die right away) and
dies when trying to print stdin.

The correct code, of course, is

if (!fp)

or

if (fp != 0)

or perhaps better yet

if (fp != fileno(stdin))

to make it even more clear.

Link: http://www.cups.org/str.php?L1675
Version: 1.1.23





More information about the cups mailing list