msvcrt: Fix close() behaviour on "no console" file descriptors.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
31bf13e92b
commit
677301a29c
|
@ -1047,7 +1047,11 @@ int CDECL MSVCRT__close(int fd)
|
|||
int ret;
|
||||
|
||||
TRACE(":fd (%d) handle (%p)\n", fd, info->handle);
|
||||
if (!(info->wxflag & WX_OPEN)) {
|
||||
|
||||
if (fd == MSVCRT_NO_CONSOLE_FD) {
|
||||
*MSVCRT__errno() = MSVCRT_EBADF;
|
||||
ret = -1;
|
||||
} else if (!(info->wxflag & WX_OPEN)) {
|
||||
ret = -1;
|
||||
} else if (fd == MSVCRT_STDOUT_FILENO &&
|
||||
info->handle == get_ioinfo_nolock(MSVCRT_STDERR_FILENO)->handle) {
|
||||
|
|
|
@ -1527,6 +1527,7 @@ static void test_invalid_stdin_child( void )
|
|||
{
|
||||
HANDLE handle;
|
||||
ioinfo *info;
|
||||
int ret;
|
||||
|
||||
errno = 0xdeadbeef;
|
||||
handle = (HANDLE)_get_osfhandle(STDIN_FILENO);
|
||||
|
@ -1538,6 +1539,21 @@ static void test_invalid_stdin_child( void )
|
|||
ok(info->wxflag == 0xc1, "info->wxflag = %x\n", info->wxflag);
|
||||
|
||||
ok(stdin->_file == -2, "stdin->_file = %d\n", stdin->_file);
|
||||
|
||||
errno = 0xdeadbeef;
|
||||
ret = fclose(stdin);
|
||||
ok(ret == -1, "fclose(stdin) returned %d\n", ret);
|
||||
ok(errno == EBADF, "errno = %d\n", errno);
|
||||
|
||||
errno = 0xdeadbeef;
|
||||
ret = close(-2);
|
||||
ok(ret == -1, "close(-2) returned %d\n", ret);
|
||||
ok(errno == EBADF, "errno = %d\n", errno);
|
||||
|
||||
errno = 0xdeadbeef;
|
||||
ret = close(STDIN_FILENO);
|
||||
ok(ret==-1 || !ret, "close(STDIN_FILENO) returned %d\n", ret);
|
||||
ok((ret==-1 && errno==EBADF) || (!ret && errno==0xdeadbeef), "errno = %d\n", errno);
|
||||
}
|
||||
|
||||
static void test_invalid_stdin( const char* selfname )
|
||||
|
|
Loading…
Reference in New Issue