mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 05:32:55 +00:00
- Correctly initialize the standard handles for console-less applications.
- Simplify _isatty and fix it to not set the errno for "invalid" handles. svn path=/trunk/; revision=14171
This commit is contained in:
parent
b4e1db6c92
commit
e52a450d86
2 changed files with 11 additions and 9 deletions
|
@ -1,5 +1,4 @@
|
||||||
#include <io.h>
|
#include <internal/file.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -7,13 +6,10 @@
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
int _isatty( int fd )
|
int _isatty(int fd)
|
||||||
{
|
{
|
||||||
struct _stat buf;
|
HANDLE hFile = fdinfo(fd)->hFile;
|
||||||
DPRINT("_isatty(fd %d)\n", fd);
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
if (_fstat (fd, &buf) < 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
if (S_ISCHR (buf.st_mode))
|
return GetFileType(hFile) == FILE_TYPE_CHAR ? 1 : 0;
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,14 +608,20 @@ BOOL __fileno_init(void)
|
||||||
|
|
||||||
if (fdinfo(0)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(0)->fdflags & FOPEN)) {
|
if (fdinfo(0)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(0)->fdflags & FOPEN)) {
|
||||||
fdinfo(0)->hFile = GetStdHandle(STD_INPUT_HANDLE);
|
fdinfo(0)->hFile = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
if (fdinfo(0)->hFile == NULL)
|
||||||
|
fdinfo(0)->hFile = INVALID_HANDLE_VALUE;
|
||||||
fdinfo(0)->fdflags = FOPEN|FTEXT;
|
fdinfo(0)->fdflags = FOPEN|FTEXT;
|
||||||
}
|
}
|
||||||
if (fdinfo(1)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(1)->fdflags & FOPEN)) {
|
if (fdinfo(1)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(1)->fdflags & FOPEN)) {
|
||||||
fdinfo(1)->hFile = GetStdHandle(STD_OUTPUT_HANDLE);
|
fdinfo(1)->hFile = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
if (fdinfo(1)->hFile == NULL)
|
||||||
|
fdinfo(1)->hFile = INVALID_HANDLE_VALUE;
|
||||||
fdinfo(1)->fdflags = FOPEN|FTEXT;
|
fdinfo(1)->fdflags = FOPEN|FTEXT;
|
||||||
}
|
}
|
||||||
if (fdinfo(2)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(2)->fdflags & FOPEN)) {
|
if (fdinfo(2)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(2)->fdflags & FOPEN)) {
|
||||||
fdinfo(2)->hFile = GetStdHandle(STD_ERROR_HANDLE);
|
fdinfo(2)->hFile = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
|
if (fdinfo(2)->hFile == NULL)
|
||||||
|
fdinfo(2)->hFile = INVALID_HANDLE_VALUE;
|
||||||
fdinfo(2)->fdflags = FOPEN|FTEXT;
|
fdinfo(2)->fdflags = FOPEN|FTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue