FreeBSD 6 Unleashed

How lpd, the Print Spooler, and the Print Queue Function in FreeBSD

lpd is the line printer daemon. This software runs in the background and waits for print requests. When it receives them, it sorts the requests through any relevant filters, converts the data to a different format if necessary, and sends the requests to the print queue.

A feature common to all modern operating systems, the print queue is an area on the hard disk where print data is stored that is waiting to be sent to the printer. Each printer connected to the system has its own separate queue and spool area. The spool area holds the data for you (in the order it was received, as though on a spool of thread) until it can be sent to the printer. It can hold multiple jobs from the same or different users.

When a user submits a job to be printed, it is put in the queue. The spooler then feeds the job to the printer when the printer is available. Jobs can have different priorities that determine in which order they will get printed. Thus the spooler and print queue act as a means for asynchronous printing, where you can create print jobs whenever you want, regardless of whether the printer is available, and the system can print them of its own accord when it's able to do so. The spooler has several advantages over simply piping data directly to the printer, as DOS used to do:

  • It allows the printer to be shared by multiple users because data can be queued up to be printed, and the program that sent the data can then forget about it.

  • It allows for background printing. Because a print job that's been dispatched is of no more interest to the program that dispatched it, you don't have to wait for the program to finish printing before you can continue working in it. It also means you can shut down the program after the job has been submitted to the queue without losing the print job.

  • It allows for some degree of fault tolerance. If the printer has to be reset, you will not lose the jobs that are in the queue and have to resubmit them. After the printer is back online, the remaining jobs in the queue should print normally, as if nothing had happened.

Generally, the spool directories are located in /var/spool. Printer output is sent to a directory within /var/spool that corresponds to your printer, whether a parallel, serial, or USB device; the first printer on the system will normally spool to /var/spool/lpd or /var/spool/output/lpd. However, this can be changed by editing a configuration file, and you will look at how to do this later in the chapter.

Категории