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);
}
}

