Both this (with Posix.Process open):

  case fork() of
    NONE => (exece(proc,proc::args,env')
             handle _ => die ("Exece of "^proc^" failed"))
  | SOME cpid => let
      val (_, result) = waitpid(W_CHILD cpid, [])
    in
      result
    end

and this:

      case fork() of
          NONE =>
          let
            val () = dup2 {old = outoutfd, new = Posix.FileSys.stdout}
            val () = dup2 {old = erroutfd, new = Posix.FileSys.stderr}
            val () = dup2 {old = ininfd, new = Posix.FileSys.stdin}
            val () =
                List.app close [errinfd, erroutfd, outinfd, outoutfd,
                                ininfd, inoutfd]
          in
            exece(executable,nm_args,env)
          end
        | SOME pid =>
          let
            val out = mkTIO_instream outinfd
            val err = mkTIO_instream errinfd
            val () = List.app close [outoutfd, erroutfd, ininfd, inoutfd]
          in
            …
          end

seem to be causing us grief, particularly on a recent Linux, PolyML 5.7 and 
under conditions of some memory load. 

The Linux is: 

Linux gemma 4.9.1-gnu-1 #1 SMP PREEMPT Sun Jan 8 16:17:57 UYT 2017 x86_64 
GNU/Linux

When strace-d, we get a lot of futex calls and interruptions from SIGCHLD. 

This is with --gcthreads=1, but pages like 

  
http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them

make me a bit nervous about how we might be falling prey to horrible problems. 

Is there a better idiom we might use?

Thanks,
Michael




_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to