pdflatex runs with -interaction=nonstopmode flag which should avoid script freezing on pdflatex errors.