Hello everybody!
My problem is that I must execute an executable file. This one may hang - as it is a compiled Pascal program that might contain an infinite loop - , so I must limit its execution time to , let us say, 10 seconds. After that time, the process must be killed.
I am almost sure that "alarm(10)" allows me to count 10 seconds, and using "signal(...)" I can receive a signal when the time limit is exceeded. But I do not really know how to execute the file (I have tried with "system(./name_of_the_file)" and the exec family of functions, but I cannot stop execution) and I do not know how to handle the signal. The process goes on and does not stop.
Thanks.
My problem is that I must execute an executable file. This one may hang - as it is a compiled Pascal program that might contain an infinite loop - , so I must limit its execution time to , let us say, 10 seconds. After that time, the process must be killed.
I am almost sure that "alarm(10)" allows me to count 10 seconds, and using "signal(...)" I can receive a signal when the time limit is exceeded. But I do not really know how to execute the file (I have tried with "system(./name_of_the_file)" and the exec family of functions, but I cannot stop execution) and I do not know how to handle the signal. The process goes on and does not stop.
Thanks.