This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: programming API to determine whether in "Cygwin environment"


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]