From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) by sourceware.org (Postfix) with ESMTPS id BE4A53858C74 for ; Fri, 27 Jan 2023 11:32:44 +0000 (GMT) Authentication-Results: sourceware.org; dmarc=permerror header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MdNoW-1om2Dh15A8-00ZRLk; Fri, 27 Jan 2023 12:32:41 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 1A03AA80C12; Fri, 27 Jan 2023 12:32:40 +0100 (CET) Date: Fri, 27 Jan 2023 12:32:40 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Cc: john daintree Subject: Re: TMP and TMPDIR mapping Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com, john daintree References: <002f01d93092$ac4f7ff0$04ee7fd0$@dyalog.com> <1139801724.20230127104437@yandex.ru> <004501d9322e$effed500$cffc7f00$@dyalog.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <004501d9322e$effed500$cffc7f00$@dyalog.com> X-Provags-ID: V03:K1:iYpY7txC56pmGHLMoNJPX4HGqwtLNDaZlAqIsFHIe2TuKTYd3UC 2eN/850NZPfWucTZ5K4zPfxJpZcXG/rPEjrn/TvxHmTm6u8FEaWFXcHyZhE8YURYdtXj/Ju nXpqAWLS4rwq3dK64coumOKaPnDpZqx7fEa8aqsx0UtjICLpx+Is6vPo2O3Jqh8Pba1yIXF 4GG5OwD2EGtVdoY8fsqhA== UI-OutboundReport: notjunk:1;M01:P0:GhTkJPSu3NU=;4ES8caOfWzKHkm32KYb0M9NVFYb 1zHi4kHI6CSlrfbRFa3UN8qXEUdc9lFk2m3WXNc2csKpAEutusVDTYZvOy/Q15tLvrb34nP3E 0LdWv2vRIZQIjmmLzE0RstVJoI9ETGNi+HIFXyPNxp/2HtM6hTRxK/qfuDkrMHD+e34xP8iQc HccWxZ23wCfEVNt2DQ8bgVYMXVqd+nKmxKVXNm73lGJRlkWPAU7Zvn3T1pxaeA2oyRyKGy9hz 1a11CrBLd9B5gkufxbWmTV4+opFK24jIuf9sT8C5AabR+KNNsnNL0QYf9Rq+kjxsoZOHgGI1o 4ve7TGpJlvlOZIrkW9QtbKLgZ6fIr0xyRZNZiiTwqMUwrejrClBfbIZyOW2Ed66S+nRNvtAok QFCgsUb6a8T/I0jSpqaj1nJ3/cn3n7JuddZ6sKu/RAKhW9ld6vQoksO2IFa83cqRzM7k/sKns efwtf7Ytp6/o+5l7XFytApScsf801F2TrWYP4bTE0r1YoRAMwrxRIyikLg0xuOOa81kQRicxQ zn6M2Uno6DTiGwHG2zUZjKiimyJV8xYeSfqQeESxC0YigoF3EF9EWgDBWpl8uwbB3r46KKhUC PqLhLVfi8yr6vedfiRKGXF+CmcU2XdCtEqW81Nld2wzBUWtAIyM8a4d7O3/InfyE2qXSU4iTH vlD77R9x298NTCV6UAtsPDC63lwMOzjIQMW6IS7pEw== X-Spam-Status: No, score=-97.1 required=5.0 tests=BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_FAIL,SPF_HELO_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Jan 27 09:08, john daintree via Cygwin wrote: > Hi Audrey. > > Here's an example of what's going on: > > >>: export TMPDIR=/cygdrive/c/tmp/jd > >>: export TMPDIR2=/cygdrive/c/tmp/jd2 > >>: cmd.exe > Microsoft Windows [Version 10.0.22621.1105] > (c) Microsoft Corporation. All rights reserved. > > C:\>echo %TMPDIR% > C:\tmp\jd > > C:\>echo %TMPDIR2% > /cygdrive/c/tmp/jd2 > > So, if I set TMPDIR and TMPDIR2 in bash, and then call cmd.exe then TMPDIR > is changed to c:\tmp\jd but TMPDIR2 is left as /cygdrive/c/tmp/jd2 > > I was hoping that there's something I can do to get the following in > cmd.exe: > > C:\>echo %TMPDIR2% > C:\tmp\jd2 # TMPDIR2 "mapped" > to c:\.... in the same way that TMPDIR is > > I hope that's a clearer example. > > Note that the actual use case is calling other Win32 programs, and the > environment variable name is different, but the above example is an attempt > to simplify the repro. > $PATH is mapped in a similar way. So I assume that there is a list of names > which are mapped. I'd like to be able to add my own names to that list. Easy: Don't call the affected Win32 executable directly. Call it through a child process. Two scenarios: - Starting the nativ executable from a shell or a Makefile: Create a wrapper script which calls TMPDIR2="$(cygpath -wa ${TMPDIR2}) before calling your native app. - Starting the nativ executable from your own process: After fork(), call const char *tmpdir2_old; char *tmpdir2_new; tmpdir2_old = getenv ("TMPDIR2"); tmpdir2_new = (char *) cygwin_create_path (CCP_POSIX_TO_WIN_A, tmpdir2_old); setenv ("TMPDIR2", tmpdir2_new, 1); free (tmpdir2_new); Then call execve or friends. Alternatively you can construct the new environment like the above for any exec call taking an environment as argument, i.e, execve, execle, execvpe. Corinna