Why does fdopen not fail here?

SunOS sun02 5.8 Generic_117350-05 sun4u sparc SUNW,Sun-Fire-V440 Solaris

The following program runs on the above architecture but does not fail as expected on fdopen:

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include <errno.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <unistd.h>

int main()

{

int fd;

if((fd = open("abc.txt", O_WRONLY|O_CREAT, 0644)) < 0)

{

fprintf(stderr,"open failed\n");

exit(1);

}

if(close(fd) < 0)

{

fprintf(stderr,"close failed.\n");

exit(1);

}

FILE *fp;

if(NULL == (fp = fdopen(fd,"w")))

{

printf("fdopen error: %s\n", strerror(errno));

exit(1);

}

}

[1359 byte] By [sapior] at [2007-11-26 11:35:59]
# 1
Well, runs without error on solaris 9.But fails with error on solaris 10.Sounds like a bug to me...
robertcohen at 2007-7-7 11:33:37 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...
# 2
After a search on SunSolve I've discovered that this is a known bug. Bug reports 4066625, 1203833 and 4517990 attest to this. Looks like the author of fdopen was having a bad day ;)Cheers,Adam
sapior at 2007-7-7 11:33:37 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...