www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/07/11/11:58:36

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
References: <18395872 DOT post AT talk DOT nabble DOT com> <0C260F619E428642BFA6380177C3ADF3067B484B AT exmsea005 DOT us DOT wamu DOT net>
Subject: RE: programming API to determine whether in "Cygwin environment"
Date: Fri, 11 Jul 2008 16:58:12 +0100
Message-ID: <002901c8e36e$ebd8c9a0$2708a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <0C260F619E428642BFA6380177C3ADF3067B484B@exmsea005.us.wamu.net>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Karr, David wrote on 11 July 2008 16:34:

> The "ant" shell script checks to see if "`uname`" contains the string
> "CYGWIN".

  Won't help here:

>> -----Original Message-----
>> From: cygwin-owner On Behalf Of Tony Last
>> Sent: Thursday, July 10, 2008 8:49 PM

>> So I'm looking for a boolean method which will allow a
>> program to tell whether it was run from within a Cygwin
>> shell. 

  Invoking uname will return the same output regardless if you launch it
from bash or cmd.exe, so can't be used to tell the two apart.


  Frankly the best method is to use standard win32 functions to identify
your parent process, then either a) check if the name contains the substring
"sh.exe", or b) check if cygwin1.dll is mapped into the parent's address
space, depending on how robust against really unlikely false positives you
wanted to be.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019