Subexec spawns a subprocess with an optional timeout.