delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/11/12/16:31:35

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
X-Authentication-Warning: ecserv7.uwaterloo.ca: www set sender to y2bismil AT engmail DOT uwaterloo DOT ca using -f
Message-ID: <1068672677.3fb2a6a541e80@ecserv7.uwaterloo.ca>
Date: Wed, 12 Nov 2003 16:31:17 -0500
From: y2bismil AT engmail DOT uwaterloo DOT ca
To: cygwin AT cygwin DOT com
Subject: creat and open failing
MIME-Version: 1.0
User-Agent: Internet Messaging Program (IMP) 3.1 / FreeBSD-4.6.2
X-Originating-IP: 207.245.22.25


Hi all,

I got a question wrt to gcc and cygwin.  I'm not sure if this is the defined
behaviour, but for some reason, the following code fails.  This is a test
program which display the failure.  
Running cygwin on windows 2000.  Compiling with mingw (no-cygwin option) 

Basically, after creat...close...  the file is set to read only (check
attributes under windows).  This causes the second to fail.  On the second run
of the program, the creat fails as well.  Any idea why the file is being set to
read only?  

Thanks,

Yamin
********************************************************
#include <io.h>
#include <stdio.h>
#include  <fcntl.h>

int main()
{
   int handle;
   handle= creat("hello.txt", O_WRONLY);
   if (handle == -1)
   {
      printf("Unable to creat file hello.txt\r\n");
   }

   write(handle, "Hello\r\n",7);
   close(handle);

   handle= open("hello.txt", O_RDWR|O_BINARY);
   if (handle == -1)
   {
      printf("Unable to open file hello.txt\r\n");
   }
   write(handle, "urdum\r\n",7);
   close(handle);


}
**************************************************

----------------------------------------
This mail sent through www.mywaterloo.ca

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