Skip to content

Commit

Permalink
BUG: Add missing limited-latex script back
Browse files Browse the repository at this point in the history
  • Loading branch information
pv committed Dec 12, 2010
1 parent 31906d1 commit 6ad0890
Showing 1 changed file with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion scripts/limited-latex.py

This file was deleted.

25 changes: 25 additions & 0 deletions scripts/limited-latex.py
@@ -0,0 +1,25 @@
#!/usr/bin/env python
"""
Many things copied from Johannes Berg's `MoinMoin Latex support`_
.. `MoinMoin Latex support`: http://johannes.sipsolutions.net/Projects/new-moinmoin-latex
"""
import resource, os, sys

LATEX = "latex"
MAX_RUN_TIME = 5 # sec

os.dup2(os.open("/dev/null", os.O_WRONLY), 0)
os.environ['openin_any'] = 'p'
os.environ['openout_any'] = 'p'
os.environ['shell_escape'] = 'f'

resource.setrlimit(resource.RLIMIT_CPU, (MAX_RUN_TIME, MAX_RUN_TIME))
try:
sys.argv[0] = LATEX
os.execvp(LATEX, sys.argv)
# does not return if successful
finally:
os.exit(2)

0 comments on commit 6ad0890

Please sign in to comment.