Fixed file descriptor leaks.
diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c
index 7b5ea3a..d546aa8 100644
--- a/dlls/x11drv/x11drv_main.c
+++ b/dlls/x11drv/x11drv_main.c
@@ -5,6 +5,7 @@
* Copyright 2000 Alexandre Julliard
*/
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/cursorfont.h>
@@ -169,6 +170,7 @@
argv0, Options.display ? Options.display : "(none specified)" );
ExitProcess(1);
}
+ fcntl( ConnectionNumber(display), F_SETFD, 1 ); /* set close on exec flag */
screen = DefaultScreenOfDisplay( display );
visual = DefaultVisual( display, DefaultScreen(display) );
root_window = DefaultRootWindow( display );
diff --git a/files/file.c b/files/file.c
index 85bdb41..f10a9bd 100644
--- a/files/file.c
+++ b/files/file.c
@@ -309,16 +309,9 @@
*/
HFILE FILE_DupUnixHandle( int fd, DWORD access )
{
- int unix_handle;
struct alloc_file_handle_request *req = get_req_buffer();
-
- if ((unix_handle = dup(fd)) == -1)
- {
- FILE_SetDosError();
- return INVALID_HANDLE_VALUE;
- }
req->access = access;
- server_call_fd( REQ_ALLOC_FILE_HANDLE, unix_handle, NULL );
+ server_call_fd( REQ_ALLOC_FILE_HANDLE, fd, NULL );
return req->handle;
}
diff --git a/scheduler/client.c b/scheduler/client.c
index f148f53..3a99781 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -390,7 +390,7 @@
if ((env_fd = getenv( "__WINE_FD" )) && isdigit(env_fd[0]))
{
fd = atoi( env_fd );
- if (fcntl( fd, F_GETFL, 0 ) != -1) return fd;
+ if (fcntl( fd, F_SETFD, 1 ) != -1) return fd; /* set close on exec flag */
}
/* retrieve the current directory */