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

Win32 create_process_env odd behaviour #8103

Closed
vicuna opened this issue Apr 14, 2003 · 2 comments
Closed

Win32 create_process_env odd behaviour #8103

vicuna opened this issue Apr 14, 2003 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 14, 2003

Original bug ID: 1637
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Steve Bishop
Version: 3.06
OS: WinXP SP1
Submission from: thalamus.cl.cam.ac.uk (128.232.8.182)

Using create_process_env to call one Caml program from another produces odd
behaviour from the Unix socket calls. See the code samples below.

If test1 is executed, test2 fails because socket() raises an exception, although
it has an error message of "The operation completed successfully".

If test1 is changed to use create_process instead then all works fine.

====test1.ml====
open Unix;;

let envarray = Array.of_list [] in
let argarray = Array.of_list [] in
let prog_path = "{the correct path}\test2.exe" in
let pid = create_process_env prog_path argarray envarray stdin stdout stderr in
ignore(waitpid [] pid);;

====test2.ml=====
open Unix;;
(try ignore(socket PF_INET SOCK_STREAM 6)
with Unix_error(e, s1, s2) -> perr_endline((error_message e)^","^s1^","^s2));
prerr_endline "Socket created OK";;

@vicuna
Copy link
Author

vicuna commented Jul 31, 2003

Comment author: administrator

Using create_process_env to call one Caml program from another produces odd
behaviour from the Unix socket calls. See the code samples below.

If test1 is executed, test2 fails because socket() raises an
exception, although it has an error message of "The operation
completed successfully".

If test1 is changed to use create_process instead then all works fine.

====test1.ml====
open Unix;;

let envarray = Array.of_list [] in
let argarray = Array.of_list [] in
let prog_path = "{the correct path}\test2.exe" in
let pid = create_process_env prog_path argarray envarray stdin stdout stderr in
ignore(waitpid [] pid);;

This is normal behavior. You're running test2.exe with an empty set
of environment variables. In particular, the PATH environment
variable isn't set, and test2.exe needs it to find the DLLs that it
used, such as the Winsock DLL.

The recommended way to create an environment for use with
Unix.create_process_env is to start with the current environment
as returned by Unix.environment(), and add or carefully remove some
variables from it.

Regards,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jul 31, 2003

Comment author: administrator

Normal behavior.

@vicuna vicuna closed this as completed Jul 31, 2003
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant