This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: expose creating windows-style envblock from current environment
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Mon, 24 Oct 2005 11:48:03 +0200
- Subject: Re: expose creating windows-style envblock from current environment
- References: <20051024010823.GA648@efn.org>
- Reply-to: cygwin-patches at cygwin dot com
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.