Loading ...
Sorry, an error occurred while loading the content.

Can't create a bash process

Expand Messages
  • Flavio
    Hello all, While trying to reuse shell class from ocamlbrowser sources (in file /usr/doc/liblablgtk-ocaml-dev/applications/browser/shell.ml on my Debian) I
    Message 1 of 2 , Nov 4, 2003
    • 0 Attachment
      Hello all,

      While trying to reuse shell class from ocamlbrowser sources (in file
      /usr/doc/liblablgtk-ocaml-dev/applications/browser/shell.ml on my
      Debian) I came across what seems very strange to me. This is a minimal
      example:

      let pid = Unix.create_process_env "bash" [||] (Unix.environment ())
      Unix.stdin Unix.stdout Unix.stdout
      in Unix.sleep 10;
      Unix.kill pid Sys.sigkill

      bash isn't started and using top I see a new process bash <defunct>.

      Using ocaml or python instead of bash as the program to launch (I
      couldn't think of any other interpreter) all works.
      Last, I tried executing ocamlbrowser and opening a new shell (File ->
      Shell...) replacing ocaml with bash and it in fact behaves oddly.

      What's wrong with bash?

      Thanks in advance,
      Flavio
    • Remi Vanicat
      ... With Unix.create_process_env the Unix exec system call is use. In the array for argument, the first one is the name of the executable being used, and bash
      Message 2 of 2 , Nov 4, 2003
      • 0 Attachment
        Flavio <sixdegreesoit@...> writes:

        > Hello all,
        >
        > While trying to reuse shell class from ocamlbrowser sources (in file
        > /usr/doc/liblablgtk-ocaml-dev/applications/browser/shell.ml on my
        > Debian) I came across what seems very strange to me. This is a minimal
        > example:
        >
        > let pid = Unix.create_process_env "bash" [||] (Unix.environment ())
        > Unix.stdin Unix.stdout Unix.stdout
        > in Unix.sleep 10;
        > Unix.kill pid Sys.sigkill
        >
        > bash isn't started and using top I see a new process bash <defunct>.

        With Unix.create_process_env the Unix exec system call is use. In the
        array for argument, the first one is the name of the executable being
        used, and bash use this information for deciding how to run (if it is
        "sh" it behave like sh, if it is "bash" it behave the default way. So
        you have to give this argument for bash to run successfully. Like in:

        let pid = Unix.create_process_env "bash" [|"bash"|] (Unix.environment ())
        Unix.stdin Unix.stdout Unix.stdout in
        Unix.sleep 10;
        Unix.kill pid Sys.sigkill

        by the way you should use Unix.wait to get ride of defunct process.

        --
        RĂ©mi Vanicat
      Your message has been successfully submitted and would be delivered to recipients shortly.