Timeout in C with exceptions