Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com From: Chris Faylor Date: Thu, 16 Mar 2000 11:45:44 -0500 To: cygwin AT sourceware DOT cygnus DOT com Subject: Re: Multiple fopens fails with permission denied Message-ID: <20000316114544.E22419@cygnus.com> Reply-To: cygwin AT sourceware DOT cygnus DOT com Mail-Followup-To: cgf AT cygnus DOT com, cygwin AT sourceware DOT cygnus DOT com References: <38D0B7F5 DOT 7D4529DB AT netinsight DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.1.8i In-Reply-To: <38D0B7F5.7D4529DB@netinsight.net>; from tomas.pihl@netinsight.net on Thu, Mar 16, 2000 at 11:31:17AM +0100 I don't believe that Windows allows you to open a com port twice with both read and write access. The usual way to deal with this is to open the file with "w+b" options. That provides a file pointer which can be both read to and written from. Be advised that the com port handling in B20.1 is not great, however. cgf On Thu, Mar 16, 2000 at 11:31:17AM +0100, Tomas Pihl wrote: >I've installed B20.1 (full.exe) on a NT4.0 SP6 machine. When I try >running the below included program I get: > >bash-2.02$ ./a.exe >Couldn't open '/dev/com1' for input >open: Permission denied > >It doesn't matter in which order I make the calls - fopen() always fail >on the second fopen. Any ideas? > >int main() >{ > FILE *fdin; > FILE *fdout; > char* device = "/dev/com1"; > > if ((fdout = fopen(device, "wb")) == NULL) { > printf("Couldn't open '%s' for output\n", device); > perror("open"); > exit(1); > } > if ((fdin = fopen(device, "rb")) == NULL) { > printf("Couldn't open '%s' for input\n", device); > perror("open"); > exit(1); > } >} > >-- >Tomas Pihl Net Insight AB >tomas DOT pihl AT netinsight DOT net Box 42093, SE-126 14 STOCKHOLM, SWEDEN >Phone: +46-8-685 04 95 Visiting address: Västberga Allé 9 >Fax: +46-8-685 04 20 http://www.netinsight.net > >-- >Want to unsubscribe from this list? >Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com > -- cgf AT cygnus DOT com Cygnus Solutions, a Red Hat company http://sourcware.cygnus.com/ http://www.redhat.com/ -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com