lprm hangs printer

hosking at convexs.UUCP hosking at convexs.UUCP
Tue Apr 1 00:05:00 AEST 1986


> /* Written  4:40 pm  Mar 24, 1986 by ables at milano.UUCP in net.bugs.4bsd */
> The REAL fix, is to /usr/src/usr.lib/lpr/rmjob.c as follows:
> 92c92
> <       if (assasinated && !startdaemon(host))
> ---
> >       if (assasinated && !startdaemon(printer))
> 
> /* End of text from convexs:net.bugs.4bsd */

One of the people here added an additional fix to this code.  There are
apparently races possible between starting/killing daemons.  Our version
of rmjob.c looks like this:

	/*
	 * Restart the printer daemon if it was killed
	 *  but first wait until the daemon is really dead
	 */
	if (assasinated) {   /* added by ACS, 11/12/85 fixes lprm bug */
		int lfd;    /* lock file descriptor */
		lfd = open(LO, O_WRONLY|O_CREAT, 0644);
		if (lfd < 0) {
			printf("cannot create %s", LO);
			exit(1);
		}

		/* when lock succeeds it's ok to restart the daemon */

		if (flock(lfd, LOCK_EX) < 0) { 

			printf("rmjob: cannot lock %s", LO);
			exit(1);
		}
		(void)close(lfd); /* implicit unlock */
	}
	if (assasinated && !startdaemon(printer))
		fatal("cannot restart printer daemon\n");
	exit(0);
}

I've never really looked at the problem in any detail, but since this
change went in, I don't recall ever seeing daemons lost due to lprm...
and it happened quite a bit before the change went in.

				Doug Hosking
				Convex Computer Corp.
				Richardson, TX
				{allegra, ihnp4, uiucdcs}!convex!hosking



More information about the Comp.bugs.4bsd.ucb-fixes mailing list