X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8731F38582AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1674819182; bh=4h9MrqPCqWRLDxBbzCL+qJLQ82yFy8oVxFJcI/RFe4E=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=axuKRox+YrRtHGY9k83tQiPvFE09JOzw/6N/X9CmTwI5y01QdNmudFwb0Jhq1TQbH GvcEhtut++L/152JJ7Kq4IJZPspl3Lzw33z1Qm55+la3VGY/a+ykjn568esv6swU8f wD8T3yVuzPlOilnFOSC5QmzWqGKWJNc4tk5O3K3M= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com Date: Fri, 27 Jan 2023 12:32:40 +0100 To: cygwin AT cygwin DOT com Subject: Re: TMP and TMPDIR mapping Message-ID: Mail-Followup-To: cygwin AT cygwin DOT com, john daintree References: <002f01d93092$ac4f7ff0$04ee7fd0$@dyalog.com> <1139801724 DOT 20230127104437 AT yandex DOT ru> <004501d9322e$effed500$cffc7f00$@dyalog.com> MIME-Version: 1.0 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 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Corinna Vinschen via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Corinna Vinschen , john daintree Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" 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 -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple