I'm writing a program (A genetic algorithm implementation) which executes another program using "system" method to calculate fitness. The problem is that another program sometimes hangs for unlimited amount of time. How can I execute a program with some time limit from C++.
Both POSIX and c++ solutions are appreciated. And more or less this will be run once application so solution doesn't have to be very elegant.
I'm running Linux CentOS distribution and am testing on Cygwin. For compiler I use gcc 4.1.2 with boost library.
Any help is apreciated