tool in C; much more robust and easier to understand, as well as avoiding the dependency on timeout (which isn't Posix).