home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
300-399
/
ff319.lzh
/
CNewsSrc
/
cnews.src.lzh
/
libc
/
stdfdopen.c
< prev
next >
Wrap
C/C++ Source or Header
|
1980-01-01
|
842b
|
39 lines
/*
* stdfdopen - ensure that the standard i/o descriptors are open,
* to avoid mayhem.
*/
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#ifndef AMIGA
# include <sys/stat.h>
#endif /* !AMIGA */
#ifndef NSYSFILE
# define NSYSFILE 3 /* hmm, not on V8 */
#endif
extern int errno;
void
stdfdopen() /* ensure standard descriptors are open */
{
/*
* 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.
*/
#ifndef AMIGA
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 /* AMIGA */
}