From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id E0E583857C79 for ; Fri, 18 Sep 2020 05:56:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E0E583857C79 Received: by mail-lj1-x22f.google.com with SMTP id u21so4052712ljl.6 for ; Thu, 17 Sep 2020 22:56:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=euJo6x6o9quoh74zdP7MKT5Tkl2cM62yn0FANISAzHQ=; b=LnxhmgyFAGQ/FfYm+eSGjb4I3YeM+JKm7Imvu8WlgPdTEuqif4JQJ1gWjJL8FshGOt wn2Gg79wUjW5+R5Uv+/r0O3vzDmjEUSXL1DBK3MUnOyCKvw3K9g4sI/DPFM5Aa1EjaGO ovfkqkt0qVV65po1zVzlCSOSBdkVRxkP6xTEBD2h0/nta5hls+fjEffa5ij0Bt2BzPAi K+vWjseihOvWZDmJFcJx8TO6w11a7VzZ+XX6AdBClLa0IdR+uXJNSiB+lxY9bAtI9ibn SXFnOmlAHD70RCB+lB8jkulwu61ZwemivqC+Tug7mNqJLqNjUEo9UbtlEsFo9Ka341oU TymQ== X-Gm-Message-State: AOAM531vUyHku/97lGFDHccvsUki7gpfQb8qPspdmyifXnGvrnI23WD0 LmlFp3LB0O92nUBYFaKT9S8= X-Google-Smtp-Source: ABdhPJy0tjbz6XNXjdj2PcMTBS1cRPtPaKd+JGQfg9YsVItqQZduJMl4GNf3ed9eDG+sGA4XJYYPiQ== X-Received: by 2002:a2e:8597:: with SMTP id b23mr11594640lji.41.1600408609378; Thu, 17 Sep 2020 22:56:49 -0700 (PDT) Received: from [100.68.255.141] (host-95-199-159-141.mobileonline.telia.com. [95.199.159.141]) by smtp.gmail.com with ESMTPSA id t6sm364257lfl.234.2020.09.17.22.56.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2020 22:56:48 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Kristian Ivarsson Mime-Version: 1.0 (1.0) Subject: Re: TMP/TEMP environment variable and /tmp Date: Fri, 18 Sep 2020 07:56:47 +0200 Message-Id: References: <423c729e-4c66-dd5e-73c0-4c636089ea35@cornell.edu> Cc: cygwin@cygwin.com In-Reply-To: <423c729e-4c66-dd5e-73c0-4c636089ea35@cornell.edu> To: Ken Brown X-Mailer: iPhone Mail (17H35) X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, MIME_QP_LONG_LINE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 05:56:52 -0000 >>>>>>>> Does anyone know the rational with this behaviour and what can be >>>>>>>> done to get hold of the (real) Windows TMP/TEMP >>>>>>>> environment-variable-values (in a >>>>>>>> (hopefully) platform independent way) ? >>>>>>> so if you are making your custom tree, try to stick on that >>>>>>> expectation and have both directories. >>>>>> In general, you are free to set TMP to a directory of your choice, >>>>>> that's the purpose of that variable, no need to sync it with some roo= t. >>>>>> There is a comment in /etc/profile: >>>>>> # TMP and TEMP as defined in the Windows environment >>>>>> # can have unexpected consequences for cygwin apps, but it does no= t >>>>>> explain what consequences that might be; probably some trouble with >>>>>> ACL/access permissions for temporary files. >>>>> Nowadays that would be $LOCALAPPDATA/Temp, or if you really insist, th= e >>>>> content of /proc/registry/HKEY_CURRENT_USER/Environment/TMP (or TEMP),= >>>>> after similarly expanding environment variable references found in tha= t. >>>>>=20 >>>>> The fact that getting Windows' idea of the user's TEMP directory is no= t >>>>> immediately platform independent may well have been part of the ration= ale >>>>> for not even trying that. >>>>=20 >>>> Well, at least it's up to the user >>>>=20 >>>> If the user sets its TMP-variable to "C:\Jabba Dabba Dooo" or "/jabba d= abba doo", I expect the value of getenv("TMP") should be just that and regar= dless of OS the value returned is whatever the variable is set to and not ma= gically changed to "/tmp" >>> Of course and that's not happening, no worries. The issue was that TMP i= s set in /etc/profile and not inherited from the Windows environment. >> Well, where my Cygwin-compiled-application is running, there=E2=80=99s no= Cygwin-installation and thus no /etc/profile so it cannot be set there (if /= etc/profile is not a built in resource in every executable), so there must b= e some text-value inside the compiled executables used in some manner someho= w >=20 > There must be something going on in your environment that you haven't told= us yet. I just tried the following test case: >=20 > #include > #include > int > main () > { > printf ("The value of TMP is %s\n", getenv ("TMP")); > } >=20 > In a Cygwin bash shell I get >=20 > The value of TMP is /tmp >=20 > Running the same executable under a Windows Command Prompt, I get >=20 > The value of TMP is /c/Users/kbrown/AppData/Local/Temp >=20 > So Cygwin converts TMP to a Posix path [*], but it doesn't change it to "/= tmp". >=20 > Ken >=20 > [*] See environ.cc:303 for a list of environment variables that Cygwin con= verts. Hmm, you=E2=80=99re right Ken I tried this before taking off for a vacation and the Windows-TMP-variable i= s extracted I now suspect that we maybe do have some logic that falls back to /tmp if th= e TMP-variable is NULL and perhaps the variable is NULL because we launch th= e process with CreateProcess and perhaps the environment-variables doesn=E2=80= =99t get inherited then ? The reason why we use CreateProcess from within a cygwin-application to crea= te another cygwin-application (instead of fork or such) might seem weird, bu= t it has its reasons I need to confirm this after the vacation-trip or if someone already know if= environment-variables =E2=80=9Cdissapear=E2=80=9D if things such as CreateP= rocess are used ? Best regards, Kristian=