From: utzoo!decvax!cca!v.wales@Ucla-Security@sri-unix Newsgroups: net.unix-wizards Title: sending signals to print spoolers Article-I.D.: sri-unix.3056 Posted: Wed Sep 1 20:04:21 1982 Received: Wed Sep 8 02:20:26 1982 From: v.wales at Ucla-Security (Rich Wales) Date: 27 August 1982 2208-PDT (Friday) We run 4.1BSD. A few people have suggested the idea of having a print spooler write its process ID in a file, so that queue-managing programs can signal it. My experience is that this can be a disaster in a busy environment unless you are running Berkeley's improved signal-handling stuff. We use home-grown printer software. Our printer daemon normally sleeps until something shows up in its queue; it wakes up every minute or so to see whether anything has arrived. Our "print" and "cancel" programs (like "lpr" and "lprm") send SIGALRM signals to the daemon to wake it up, so that people don't have to wait a whole minute for their request to be acted upon by the daemon. Some time ago, we started having a horrible problem -- every day or so, the printer daemon would unexpectedly DIE. No log-file entry, no core dump -- it would just vanish. Naturally, this was very disconcerting both to our users and to the author of the program (me)! After several weeks, I finally traced the problem down to the fact that the daemon was using "signal" instead of "sigset" to handle SIGALRMs. When things got really busy, the daemon apparently sometimes got two SIGALRMs in rapid succession -- the second one being fatal. Fixing this problem was tricky, by the way, because the "sleep" routine in the standard C library uses "signal". I fixed this by adding to the "jobs" library a "sleep" that calls "sigset" instead of "signal". This way, if you use the "jobs" library, you automatically get a watertight "sleep" routine. The dying-daemon problem has never recurred, needless to say. -- Rich