-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CCUnix] add function to call a process with a timeout #143
Comments
That would be useful indeed, but I haven't found a way of doing it without multi-threads. Technical suggestions welcome. |
Could this go into a |
@hcarty I think it should be in the unix sub-library anyway, but the problem is I'm not sure how to do it even with threads ( Maybe we can do sth where we fork manually and setup a ulimit/rlimit, or setup some alarm ( |
I tried this little experiment: let f () =
let st = Unix.gettimeofday() in
let pid = Unix.fork() in
if pid=0 then (
Unix.alarm 4;
Unix.execv "sleep" [| "sleep"; "10" |]
) else (
Unix.waitpid [] pid;
Printf.printf "done (%.2f)" (Unix.gettimeofday() -. st)
);;
f();; and it does print "done" after 4s. So it might work. What do you think? |
That's pretty promising - I didn't realize the signal would persist like that. It would be nice to have something which doesn't rely on |
The subject says it all.
The text was updated successfully, but these errors were encountered: