Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <52360.213.38.17.50.1042048337.squirrel@raq299.uk2net.com> In-Reply-To: <20030108162949.GA16269@grub.ath.cx> References: <20030108162949 DOT GA16269 AT grub DOT ath DOT cx> Date: Wed, 8 Jan 2003 17:52:17 -0000 (GMT) Subject: Re: Problem going from .o -> .dll From: "Dave Hooper" To: "Travis Whitton" Cc: cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal > $ ./driver.exe > EOF > g(smiley face)Err: Close failed This is not a forum for debugging other peoples' code, but ... 1. You are using HANDLE * instead of HANDLE 2. Your logic for nul termination is totally wrong: c->buffer[nBytesRead + 1] = '\0'; should be c->buffer[nBytesRead] = '\0'; (think about why) 3. Your logic for detecting End Of File also looks wrong - Quote from msdn.microsoft.com: "The ReadFile code to check for the end-of-file condition (eof) differs for synchronous and asynchronous read operations. When a synchronous read operation reaches the end of a file, ReadFile returns TRUE and sets *lpNumberOfBytesRead to zero". 4. I would also personally check that CreateFile isn't returning NULL (as well as your current test for INVALID_HANDLE_VALUE) as that will also indicate an error. I also habitually set nBytesRead=0 before calling ReadFile although I cannot honestly tell you if that will make a difference. Try that little lot and see what happens. At the worst it will let you diagnose any real error correctly. d -- 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/