[XeTeX] Running XeTeX / XeLaTeX through a named pipe

Brian Hunt brianmhunt at gmail.com
Fri Sep 18 07:33:33 CEST 2009

Hello everyone,

I've got a very persnickety problem: I want to have XeLaTeX read its
data from a named pipe (FIFO).

I've posted this problem on StackOverflow:

Unfortunately none of the responses there have been helpful. The gist
of the problem is (duplicating what's on that site):

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:

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

$ echo "\\end" > fifo

Then the `$ xetex fifo` output is:

  This is XeTeXk, Version 3.1415926-2.2-0.999.6 (Web2C 7.5.7)
   %&-line parsing enabled.
   entering extended mode

The XeTeX process never ends. How can you get this process (i.e. file
parsing) 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)?

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 session:

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

One can make this work with LaTeX with the following hack:

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

Unfortunately, XeLaTeX has no apparent solution and a hack is beyond
me. I don't know the innards of XeTeX at all, though I've spent some
time rooting through TRUNK/texk/web2c/xetexdir/xetex.ch, but I'm lost
in there.

If I do the following:

$ echo "\\end" > t
$ echo "\\end" > t

Then XeTeX presents with:
This is XeTeXk, Version 3.1415926-2.2-0.999.6 (Web2C 7.5.7)
 %&-line parsing enabled.
entering extended mode

... and you have to type '\end' on the command line to make it end (horrors!).

If you do this with XeLaTeX:

$ echo "\\documentclass{article}\\begin{document}asdf\\end{document}" > fifo
$ echo "\\documentclass{article}\\begin{document}asdf\\end{document}" > fifo

This is XeTeXk, Version 3.1415926-2.2-0.999.6 (Web2C 7.5.7)
 %&-line parsing enabled.
entering extended mode
LaTeX2e <2005/12/01>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2008-06-18, ngerman-x-2008-06-18, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, la
tin, mongolian, mongolian2a, bokmal, nynorsk, polish, portuguese, romanian, rus
sian, sanskrit, serbian, slovak, slovenian, spanish, swedish, turkish, ukenglis
h, ukrainian, uppersorbian, welsh, loaded.

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

l.1 o

I've been staring at this for way too long, and I've absolutely no
idea whatsoever how to work around this problem. I'd be very much
obliged for any suggestions, input and thoughts you may be able to

Thank you.

All the best,


More information about the XeTeX mailing list