This is the mail archive of the cygwin@cygwin.com 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: starting a CYGWIN app from a Windows Service


Thanks Dan. Using "rt" fixed the problem for the moment.

I will still need to understand exactly why there was a difference though. CYGWIN is undefined in both circumstances. What I don't understand is the "system" vs. "user" mount types. The file is on the local file system, (C:/.../file.txt) so I don't know if that applies here.

-Mark


-----Original Message-----
From:	Dan Vasaru [mailto:dvasaru@broadpark.no]
Sent:	Wed 10/16/2002 5:09 PM
To:	Madsen, Mark; cygwin@cygwin.com
Cc:	
Subject:	RE: starting a CYGWIN app from a Windows Service
Mark,

As Chris suggested, if you want consistent behaviour under cygwin, always
open text files in text mode (O_TEXT or "rt").
Even better, wrt portability to Unix platforms, is to:

1. open the file in binary mode
2. be prepared to accept both CRLF- and LF-style text files (i.e. strip the
CR yourself)

This way, your software will always "behave" when encountering a Windows
file while running on a Unix platform.

Dan

PS. To explain the behaviour you're seeing you have to check 4 places:

value of the CYGWIN environment variable when running as a service
value of the CYGWIN environment variable when running as yourself
system mount types
user mount types

There's probably a difference in the mount mode or CYGWIN variable between
the 2 cases.

Dan

-----Original Message-----
From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com]On Behalf
Of Madsen, Mark
Sent: Wednesday, October 16, 2002 11:21 PM
To: cygwin@cygwin.com
Subject: starting a CYGWIN app from a Windows Service


When I run an application that uses the cygwin1.dll from either a Windows
Service and then from the command line I get different results when trying
to read a text file.

As a Windows Service:
I use fopen and fgets to read a DOS text file and the CR/LF combinations are
handled properly. Meaning that I only see the single LF.

Running from a DOS command line:
Using the exact same executable image as above, both characters are in the
buffer.

What I know:
Both instances use the very same DLL image. (I deleted it and both instances
complain about the DLL missing.)

Both instances are reading the exact same file, not two different copies.

I tried working with the CYGWIN environment variable with no effect on the
outcome.

Any help would be greatly appreciated.
Thanks,
Mark

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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]