2
votes

I'm running LaTeX on a named pipe fifo on Unix. I create the fifo like-so:

$ mkfifo fifo

I then run LaTeX like-so:

$ latex fifo

This process blocks and has no output until I write to the fifo from another shell:

$ echo "\\end" > fifo

Then the $ latex fifo output becomes:

This is pdfTeXk, Version 3.1415926-1.40.9 (Web2C 7.5.7)
%&-line parsing enabled.
entering extended mode

However, the LaTeX process never ends. How can you get LaTeX to end? I've tried sending it chr(0) and chr(4) (i.e. ctrl-d), but neither works. Is there some command that will tell LaTeX to exit (i.e. something like \exit)?

Thanks for reading.

EDIT:

It is noteworthy that when you run tex instead of a variant of latex then the following works as expected:

$ echo "story\\end" > fifo

(meanwhile, in the tex console)

$ tex fifo
This is TeX, Version 3.1415926 (Web2C 7.5.7)
(./fifo [1] )
Output written on fifo.dvi (1 page, 212 bytes).
Transcript written on fifo.log.

However, although Leslie Lamport notes in A Document Preparation System LaTeX on page 233 that \end has been replaced by \end{document}, neither of the following ends a LaTeX session:

$ echo "\begin{document}story\end{document}"
$ echo "\\begin{document}story\\end{document}"
2

2 Answers

2
votes

I would suggest allow your shell to direct the fifo pipe to the standard in.

latex < fifo

When I do that, I get this output first:

This is pdfeTeXk, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=latex 2009.3.25)  18 SEP 2009 14:25
entering extended mode
 file:line:error style messages enabled.
 %&-line parsing enabled.

and then after the echo command:

**\end

*
! Emergency stop.
<*> \end

End of file on the terminal!
1
votes

If I echo a blank line into the fifo first and then echo the rest of the document, it works fine.

mkfifo test
latex test

Other console:

echo "" > test
echo "\documentclass{report}\begin{document}asdf\end{document}" > test

First console:

xdvi test

My guess is that LaTeX makes two passes of the file whereas TeX does not. On the first pass, LaTeX tries to determine something, then it closes the file, and reopens it for the second pass.