Skip to content
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

Unix.system does not handle EINTR #5953

vicuna opened this issue Mar 15, 2013 · 2 comments

Unix.system does not handle EINTR #5953

vicuna opened this issue Mar 15, 2013 · 2 comments


Copy link

@vicuna vicuna commented Mar 15, 2013

Original bug ID: 5953
Reporter: @diml
Assigned to: @diml
Status: closed (set by @xavierleroy on 2015-12-11T18:18:34Z)
Resolution: open
Priority: low
Severity: minor
Version: 4.01.0+dev
Target version: 4.01.0+dev
Category: otherlibs
Monitored by: @dbuenzli

Bug description

Right now Unix.system calls waitpid and does not handle EINTR. This means that if a signal handler is set somewhere else in the program a call to Unix.system may fail with this error.

I think Unix.system should waitpid again until it does not fail with EINTR since:

  • this is what the system(3) function of the libc does
  • the user does not have the pid of the sub-process so it cannot restart the call if it is interrupted

The attached patch replace the call to waitpid in Unix.system by one to waitpid_non_intr.

Steps to reproduce

#load "unix.cma";;

Sys.set_signal Sys.sigchld (Sys.Signal_handle ignore);;

  • : unit = ()

let ic = Unix.open_process_in "sleep 5";;

val ic : in_channel =

Unix.system "sleep 10";;

Exception: Unix.Unix_error (Unix.EINTR, "waitpid", "").

File attachments

Copy link

@vicuna vicuna commented Mar 20, 2013

Comment author: @diml

If nobody objects I'll merge the patch.

Copy link

@vicuna vicuna commented Mar 22, 2013

Comment author: @diml

Applied in revisions 13421 and 13422.

@vicuna vicuna closed this Dec 11, 2015
@vicuna vicuna added this to the 4.01.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants