next up previous contents
Next: Customizing the Print Environment Up: Printing Data Previous: dstool Format   Contents

Piping Data to Printers

Rather than writing data into a PostScript file, it is possible to send data directly to a printer which reads PostScript (for example, the SPARCprinter, the Apple LaserWriter, and the Linotype Linotronic 300 typesetter). This is done by selecting the Printer choice option on the Destination exclusive setting. Type the name of the printer in the Printer text field (referred to below as printername) and choose the remaining print options as desired.

When the Print command button is selected, dstool opens a pipe and spawns the child process lpr -Pprintername. The PostScript data is then written into this pipe. If all goes well, the printer will interpret the PostScript data and produce an image.

There are situations in which the child process will fail. If this occurs, the operating system will notify dstool of the death of the child. Depending upon how the child died, dstool may or may not be able to recover from the error. Possible errors include: a broken pipe, a bad argument to a system call, and the printer daemons inability to create a temporary file (for example, if the size of your data exceeds the size of temporary file space). If sending data directly to a printer does not work for some reason, we suggest writing the data to a PostScript file and manually sending the file to a printer.

While we cannot foresee all possible sources of error, we have made provisions for the case in which a child process dies because of a typing error. If an incorrect printername is given to dstool, the spawned lpr command will terminate with the error message lpr: printername: unknown printer sent to standard error. As dstool continues to attempt to write into the (now broken) pipe, it will be sent the signal SIGPIPE, indicating an an attempt to write on a pipe with no one to read it. We now describe how this error is handled by dstool.

When the Print command button is selected, dstool uses the C library function signal() to declare that if a SIGPIPE signal is generated, then execution is to pass immediately to an error function called broken_pipe_error(). This function executes a non-local jump using the library functions setjmp() and longjmp(). When a SIGPIPE error is received, dstool stops writing to the pipe, notifies the user of the error, and then returns control of the program to the window manager.

Some debuggers, including Sabertool, allow you to follow dstool as it catches the signal and then pases control to broken_pipe_error(). It may be necessary to inform the debugger that it should ignore signal SIGPIPE. In sabertool, the command to do this is ignore SIGPIPE.


next up previous contents
Next: Customizing the Print Environment Up: Printing Data Previous: dstool Format   Contents
root
1998-11-02