expose creating windows-style envblock from current environment

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Oct 24 09:48:00 GMT 2005


On Oct 23 18:08, Yitzchak Scott-Thoennes wrote:
> I need to translate the current environment in a cygwin C program to
> an envblock suitable for calling CreateProcess directly, and couldn't
> think of a better way than the following patch.

I'm wondering why that's necessary at all.  You have access to the app's
POSIX environment and you know by a simple look into Cygwin which
variables have to be path converted and which not.  That can be done
using cygwin_conv_to_win32_path/cygwin_posix_to_win32_path_list.  Looks
like a task easily accomplished inside of the application.

> But I think there's something I'm not understanding; with the free()
> calls in place, it coredumps, though checking the code in environ.cc
> seems to show that all the freed chunks should have been properly
> allocated.

envp and the envp members are allocated on the cygheap using cmalloc()
and cstrdup() so you must free them with cfree().

> As an aside, does the build_env call in spawn.cc leak?

How?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat, Inc.



More information about the Cygwin-patches mailing list