mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 12:33:41 +00:00
msvcrt: Set errno when close() is called on already closed fd.
Based on a patch by Olly Betts. Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
53bab55d30
commit
67926ec8c3
|
@ -1051,7 +1051,7 @@ int CDECL MSVCRT__close(int fd)
|
|||
if (fd == MSVCRT_NO_CONSOLE_FD) {
|
||||
*MSVCRT__errno() = MSVCRT_EBADF;
|
||||
ret = -1;
|
||||
} else if (!(info->wxflag & WX_OPEN)) {
|
||||
} else if (!MSVCRT_CHECK_PMT_ERR(info->wxflag & WX_OPEN, MSVCRT_EBADF)) {
|
||||
ret = -1;
|
||||
} else if (fd == MSVCRT_STDOUT_FILENO &&
|
||||
info->handle == get_ioinfo_nolock(MSVCRT_STDERR_FILENO)->handle) {
|
||||
|
|
|
@ -2466,6 +2466,12 @@ static void test_close(void)
|
|||
ok(!GetHandleInformation(h, &flags), "GetHandleInformation succeeded\n");
|
||||
ok(close(fd2), "close(fd2) succeeded\n");
|
||||
|
||||
/* test close on already closed fd */
|
||||
errno = 0xdeadbeef;
|
||||
ret1 = close(fd1);
|
||||
ok(ret1 == -1, "close(fd1) succeeded\n");
|
||||
ok(errno == 9, "errno = %d\n", errno);
|
||||
|
||||
/* test close on stdout and stderr that use the same handle */
|
||||
h = CreateFileA("fdopen.tst", GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
|
|
Loading…
Reference in a new issue