# Is there a way for LaTeX to always return?

I'm currently writing a Python program that can automate detection of whether a certain command is permitted in math mode without using any packages.

For the purpose of testing I add \documentclass{article} \begin{document}$ before a command to be tested and $\end{document} after it. Then I save it to a file using a randomly generated filename and use latex <filename>+'.tex' to TeX the file.

If the command is actually permitted the process ends and I can obtain a return code of 0. On the other hand when TeXing doesn't work instead of returning an error code the process simply doesn't end.

Is there a way to run LaTeX so that the process always return even if there is an error?

• Nevermind. There is -halt-on-error . Problem solved! – Ying Zhou May 5 '19 at 19:55
• Not really. There are cases where this does not work for unknown reasons. I really don't want to put some form of timeout there since it will be machine-dependent. – Ying Zhou May 5 '19 at 20:46
• most editors will get some error feedback when run using one of the nonstop options run (pdf)latex --help to see most choices especially -interaction=errorstopmode and nonstopmode – user170109 May 5 '19 at 21:03
• "machine dependent" should be fairly trivial all windows should respond to taskkill should be similar kill for *nix ? the timer is dwn to the app – user170109 May 5 '19 at 22:17
• you can quite easily write tex code that runs a long time: tex.stackexchange.com/questions/tagged/compiling. So without some timeout it will not work. – Ulrike Fischer May 5 '19 at 22:29