home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD2.img
/
d4xx
/
d473
/
cnewssrc
/
cnews_src.lzh
/
libc
/
stdfdopen.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-25
|
949b
|
41 lines
/*
* stdfdopen - ensure that the standard i/o descriptors are open,
* to avoid mayhem.
*/
#include <stdio.h>
#include <errno.h>
#ifndef __STDC__
extern int errno;
#endif
#ifdef unix
# include <sys/types.h>
# include <sys/stat.h>
#endif /* unix */
#ifndef NSYSFILE
#define NSYSFILE 3 /* hmm, not on V8 */
#endif
void
stdfdopen() /* ensure standard descriptors are open */
{
#if !defined(AZTEC_C) && !defined(LATTICE)
/*
* [FIXME] -- stdfdopen()
* As far as I know, the best the Amiga could do is
* use iomode() to try to change the mode of the 'level 1'
* file handle (descriptor) and see if an error was
* returned! ... forget it for now -- assume it's okay.
* Could it *really* be a problem anyway???
*/
register int fd;
struct stat stbuf;
for (fd = 0; fd < NSYSFILE; fd++)
if (fstat(fd, &stbuf) < 0 && errno == EBADF)
if (open("/dev/null", 2) != fd) /* open read/write */
exit(1); /* bad news */
#endif
}