Skip to content

passing env in Lwt_process doesn't work on Windows #966

@mroch

Description

@mroch

#define string_option(opt) \
(Is_block(opt) ? caml_stat_strdup_to_os(String_val(Field(opt, 0))) : NULL)
char_os
*progs = string_option(prog),
*cmdlines = caml_stat_strdup_to_os(String_val(cmdline)),
*envs = string_option(env),

An "environment block" consists of a null-terminated block of null-terminated strings. Using caml_stat_strdup_to_os doesn't work because it only supports null-terminated strings -- it stops on the first \0 and misses the rest of the block.

ocaml itself deals with this here:

https://github.com/ocaml/ocaml/blob/000d15d4e229e895612177590df08d0364b1cb04/otherlibs/unix/createprocess.c#L122-L127

but an external library like Lwt can't do the same thing. see ocaml/ocaml#11449 re: adding a public API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions