Hi!
I'm currently working on a website where any user can use a compiler without installing it on his computer.
My PHP page calls a shell script which is used to call the compiler. The outputs are redirected to files and then the PHP page displays the content of these files. Problem is that the compiler can do infinite loop. If that happens i have to kill it.
Here is the command i use (in the shell script)
(elan is the name of the compiler)
<PRE>
#!/bin/tcsh
((elan $2 $3.lgi > elan.out) 2> elan.err )&
kill -9 $! | at now + 30 minutes
</PRE>
If i use '&' the 'elan' command is run in background and the PHP page won't wait for the end of the task and will look for the files elan.out and elan.err but they are not generated yet. It doesn't work but i can get the PID of the task (with $!) and then kill it.
If i don't use '&' the PHP page will wait the end of the task and it will work except that i can't kill the task 'elan' if it goes into an infinite loop.
Does anyone have an idea ?
Thanks.
Nicolas.