delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/12/03/20:42:42

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
X-Authority-Analysis: v=1.0 c=1 a=bJIJG6xM5qMA:10 a=W2Cyk0x8aJkA:10 a=xe8BsctaAAAA:8 a=7w4tqSCS6Kb1p8cL2ZkA:9 a=1p6QVt3PaUNe_Hgw_AqoGTN2M94A:4 a=eDFNAWYWrCwA:10 a=rPt6xJ-oxjAA:10
Message-ID: <49373554.6000507@byu.net>
Date: Wed, 03 Dec 2008 18:41:40 -0700
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081105 Thunderbird/2.0.0.18 Mnenhy/0.7.5.666
MIME-Version: 1.0
To: cygwin AT cygwin DOT com, mring111 AT yahoo DOT com
Subject: Re: Using -mno-cygwin causes different program behavior
References: <20825507 DOT post AT talk DOT nabble DOT com>
In-Reply-To: <20825507.post@talk.nabble.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to C-Programmer on 12/3/2008 6:29 PM:
> But if I compile using the following command line argument:
> $ gcc -mno-cygwin -o ioProg1 ioProg1.c

Then you are no longer using cygwin, and this is almost more of a question
for the mingw list.

> I find that the DLL being used is msvcrt.dll and the program behaves as if
> the gets( name ); line had come before the printf("What is your name?");
> line. Very strange!
> 
> Any ideas on why this is happening?

Yes.  It's called buffering.  Native Windows apps have no idea that cygwin
emulates pty's with pipes, and blindly assume that all pipes are
non-interactive.  For performance reasons, when talking to a
non-interactive client, all stdio libraries perform block buffering
instead of line buffering when stdout is determined to be non-interactive.
 So, because you are running a native windows app in a cygwin console,
your app doesn't realize that you wanted line buffering, and so you don't
see output until 4k or end of process, even though the printf completed
before the gets.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9 AT byu DOT net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkk3NVQACgkQ84KuGfSFAYBbLgCg1fPBj1EjWjV//aa8FZ5+TSNA
4KUAoKiFDW6hFR0hJD857TNEa7gSAiFK
=usqi
-----END PGP SIGNATURE-----

--
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