# MathKernel with -noprompt hangs indefinitely when converting simple TeX expression

If I enter

MathKernel -noprompt -run 'ToExpression["1", TeXForm]; Exit[]'


the kernel hangs, apparently while running TeX.exe as a mathlink (see below). But when I remove -noprompt, it runs just fine. Similar results hold if I pass these commands (to either MathKernel or MathematicaScript) as a script.

Alternatively, even with -noprompt, any of the other formats accepted by ToExpression work just fine.

Any ideas why this happens?

Rather than printing the output, I could just write to file and send all the prompt garbage to /dev/null, but this really doesn't fit into my tool chain very well. So I'd appreciate any solutions or workarounds. I'm running Mathematica 9.0 for Mac OS X x86 (64-bit) on OS X 10.6.8.

My evidence for believing that it's TeX.exe causing the problem is that my processes look like this

2772 s000  S+     0:00.28 /Applications/Local/Mathematica.app/Contents/MacOS/MathKernel -noprompt -run Print[ToExpression["1", TeXForm]];Exit[]
2773 s000  S+     0:00.04 /Applications/Local/Mathematica.app/SystemFiles/Converters/Binaries/MacOSX-x86-64/TeX.exe -ml -mathlink -linkmode connect -linkprotocol SharedMemory -linkname jv5_shm


Now, without -noprompt, I also see TeX.exe in the process list with the exact same arguments. But it's only there briefly, and it returns normally. Also, I can run file TeX.exe, and see that it is indeed a Mac executable (not Windows, as the name would suggest).

-
The name of TeX.exe is the same on all platforms, but it doesn't mean that it's invalid or unused on Mac or Linux. I can reproduce the problem on OS X 10.8 too. – Szabolcs Oct 1 '13 at 23:06
A workaround is to put the commands in a text file (file.m) and run it using math -script file.m – Szabolcs Oct 1 '13 at 23:07