delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/11/00:46:20

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
Date: Thu, 11 Mar 2004 12:12:36 +0000 (GMT)
From: Ghanshyam <gshyam AT denver DOT india DOT mentorg DOT com>
To: cygwin AT cygwin DOT com
cc: harsh_arora AT mentorg DOT com
Subject: 1.5.5.1 fgetc returns no error for bad file descriptor
Message-ID: <Pine.LNX.4.10.10403111204020.4328-100000@denver.india.mentorg.com>
MIME-Version: 1.0

Hi All,
    
    The 9th assertion of fgetc in "IEEE std 2003.1-1992 Test Methods for
Measuring Conformance to Posix-Part1 System Interface" document states:
    When the stream pointer argument addresses a file descriptor that
is not open for reading, then a call to fgetc()returns a value of 
EOF and sets errno to [EBADF].
The current implementation does not set any errno. It says "No error". 

here is the small program which i compiled using gcc under cygwin and it
prints 'FAILURE: No error'

#include<stdio.h>
#include<errno.h>
int main()
{
	char path[]="./testfile";
	FILE *p;
	p=fopen(path,"w"); /*file descriptor is open for writing!*/
	fgetc(p);	/*must set errno to EBADF*/
	if(errno!=EBADF)
		perror("FAILURE");
	else
		printf("PASS\n");
return 0;
}


Regards,
ghanshyam



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