From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.138]) by sourceware.org (Postfix) with ESMTPS id 91DE33857C4C for ; Fri, 18 Sep 2020 03:56:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 91DE33857C4C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=SystematicSw.ab.ca Authentication-Results: sourceware.org; spf=none smtp.mailfrom=brian.inglis@systematicsw.ab.ca Received: from [192.168.1.104] ([24.64.172.44]) by shaw.ca with ESMTP id J7VJkNCXkHxtDJ7VKkdxw7; Thu, 17 Sep 2020 21:56:10 -0600 X-Authority-Analysis: v=2.4 cv=Ce22WJnl c=1 sm=1 tr=0 ts=5f642fda a=kiZT5GMN3KAWqtYcXc+/4Q==:117 a=kiZT5GMN3KAWqtYcXc+/4Q==:17 a=IkcTkHD0fZMA:10 a=sqJvUu9dCfN0I8DIGlAA:9 a=QEXdDO2ut3YA:10 a=BiZDYxNxVecA:10 Reply-To: cygwin@cygwin.com Subject: Re: TMP/TEMP environment variable and /tmp To: cygwin@cygwin.com References: <3423eb8a-447e-015e-9eb7-84d455db0c4f@towo.net> <423c729e-4c66-dd5e-73c0-4c636089ea35@cornell.edu> <687db96b-9f7e-8c50-4673-14435a20864b@cornell.edu> From: Brian Inglis Autocrypt: addr=Brian.Inglis@SystematicSw.ab.ca; prefer-encrypt=mutual; keydata= mDMEXopx8xYJKwYBBAHaRw8BAQdAnCK0qv/xwUCCZQoA9BHRYpstERrspfT0NkUWQVuoePa0 LkJyaWFuIEluZ2xpcyA8QnJpYW4uSW5nbGlzQFN5c3RlbWF0aWNTdy5hYi5jYT6IlgQTFggA PhYhBMM5/lbU970GBS2bZB62lxu92I8YBQJeinHzAhsDBQkJZgGABQsJCAcCBhUKCQgLAgQW AgMBAh4BAheAAAoJEB62lxu92I8Y0ioBAI8xrggNxziAVmr+Xm6nnyjoujMqWcq3oEhlYGAO WacZAQDFtdDx2koSVSoOmfaOyRTbIWSf9/Cjai29060fsmdsDLg4BF6KcfMSCisGAQQBl1UB BQEBB0Awv8kHI2PaEgViDqzbnoe8B9KMHoBZLS92HdC7ZPh8HQMBCAeIfgQYFggAJhYhBMM5 /lbU970GBS2bZB62lxu92I8YBQJeinHzAhsMBQkJZgGAAAoJEB62lxu92I8YZwUBAJw/74rF IyaSsGI7ewCdCy88Lce/kdwX7zGwid+f8NZ3AQC/ezTFFi5obXnyMxZJN464nPXiggtT9gN5 RSyTY8X+AQ== Organization: Systematic Software Message-ID: <7cdf4b72-bc51-0c9f-de36-8494eeba4083@SystematicSw.ab.ca> Date: Thu, 17 Sep 2020 21:56:09 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <687db96b-9f7e-8c50-4673-14435a20864b@cornell.edu> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfHeCX3j/Ax/UDmOjCt0iFvC1gb9g1bULdCMe+mUNrT2W4q+OXhgLJwi2Jt8s+UHtPdpDmBWDE+fepHfLLNnaFtci0GiA7yNyQOKIdrFByn7SFHyJOtAq veppuBrPYV2QHKy3AVm9QsIWFmtk8djyk4a5szKiOV9aawMrQ0zvvtxKnByr9AJMFkXFszSuIZ6jTdRRghOAsxR+ieFKq/ZLK+k= X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.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: , X-List-Received-Date: Fri, 18 Sep 2020 03:56:13 -0000 On 2020-09-17 20:17, Ken Brown via Cygwin wrote: > On 9/17/2020 7:58 PM, Doug Henderson via Cygwin wrote: >> On Thu, 17 Sep 2020 at 15:56, Ken Brown via Cygwin <> wrote: >>> >> >> #include >> #include >> int >> main () >> { >>      char *temp_nam; >>      char *p_tmp_nam; >> >>      printf ("$TMP      is '%s'\n", getenv ("TMP")); >>      printf ("$TMPDIR   is '%s'\n", getenv ("TMPDIR")); >>      printf ("$TEMP     is '%s'\n", getenv ("TEMP")); >>      printf ("P_tmpdir  is '%s'\n", P_tmpdir); >>      p_tmp_nam = tmpnam(0); >>      printf ("tmpnam()  is '%s'\n", p_tmp_nam); >>      temp_nam = tempnam(0, 0); >>      printf ("tempnam() is '%s'\n", temp_nam); >>      free(temp_nam); >> } >> >> >> # start a new shell >> $ sh >> $ TMP= TEMP= ./show_tmp >> $TMP      is '' >> $TMPDIR   is '(null)' >> $TEMP     is '' >> P_tmpdir  is '/tmp' >> tmpnam()  is '/tmp/t707.0' >> tempnam() is '/tmp/ffffd187.2' >> >> # start cmd.exe >> $ /cygdrive/c/windows/system32/cmd.exe >> Microsoft Windows [Version 10.0.18363.1082] >> (c) 2019 Microsoft Corporation. All rights reserved. >>> set TMP= >>> set TEMP= >>> show_tmp >> $TMP      is '(null)' >> $TMPDIR   is '(null)' >> $TEMP     is '(null)' >> P_tmpdir  is '/tmp' >> tmpnam()  is '/tmp/t709.0' >> tempnam() is '/tmp/ffffd189.2' >> >> P_tmpdir is defined in > > Sorry, but I'm missing your point.  How is this related to Kristian's claim that > Cygwin is changing the value of the TMP environment variable to "/tmp"? It demonstrates that Cygwin programs don't themselves change TEMP/TMP, unless they call an API routine that generates a filename in a directory, when the filesystem handling may translate a nonexistent or unmounted /tmp/ to ../tmp/. That jives with the defaults I see in the registry and in the cmd environments: $ regtool list -v /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session\ Manager/Environment | grep 'T.*MP' TEMP (REG_EXPAND_SZ) = "%SystemRoot%\TEMP" TMP (REG_EXPAND_SZ) = "%SystemRoot%\TEMP" $ regtool list -v /proc/registry/HKEY_CURRENT_USER/Environment | grep 'T.*MP' TEMP (REG_EXPAND_SZ) = "%UserProfile%\AppData\Local\TEMP" TMP (REG_EXPAND_SZ) = "%UserProfile%\AppData\Local\TEMP" C:\Windows\system32>set | grep "T.*MP" TEMP=C:\Windows\TEMP TMP=C:\Windows\TEMP C:\Windows\system32>which env /usr/bin/env C:\Windows\system32>env | grep "T.*MP" TEMP=/cygdrive/c/Windows/TEMP TMP=/cygdrive/c/Windows/TEMP C:\Users\...>set | grep "T.*MP" TEMP=C:\Users\...\AppData\Local\Temp TMP=C:\Users\...\AppData\Local\Temp C:\Users\...>env | grep "T.*MP" TEMP=/cygdrive/c/Users/.../AppData/Local/Temp TMP=/cygdrive/c/Users/.../AppData/Local/Temp and I know you can just delete those environment variables and registry keys at the risk of upsetting any Windows programs that need temp space and do not provide an accessible fallback. The same goes for any Cygwin script or program: each application needs to check it has access to any output locations: the directory is writable and the file can be created e.g. in /var/log/ or /tmp/, or try to create a directory, or try elsewhere /usr/tmp/, /var/tmp/, or create that, or try the current directory ./ or home directory $HOME/, known paths $USERPROFILE/ or $LOCALAPPDATA/Temp/, or exit with a failure condition. I think we need to see the environment or registry and application code around creating the file to diagnose the cause, but I expect the environment may not define TMPDIR/TMP/TEMP, the application provides no accessible fallback(s), and Cygwin defaults the path. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in IEC units and prefixes, physical quantities in SI.]