Commit a5a872ef authored by Alexandre Julliard's avatar Alexandre Julliard

Use the new send_fd mechanism for the set_console_fd server request.

parent 9fd15a9f
...@@ -757,8 +757,8 @@ struct set_console_fd_request ...@@ -757,8 +757,8 @@ struct set_console_fd_request
{ {
REQUEST_HEADER; /* request header */ REQUEST_HEADER; /* request header */
IN handle_t handle; /* handle to the console */ IN handle_t handle; /* handle to the console */
IN handle_t handle_in; /* handle of file to use as input */ IN int fd_in; /* file descriptor to use as input */
IN handle_t handle_out; /* handle of file to use as output */ IN int fd_out; /* file descriptor to use as output */
IN int pid; /* pid of xterm (hack) */ IN int pid; /* pid of xterm (hack) */
}; };
...@@ -1611,7 +1611,7 @@ union generic_request ...@@ -1611,7 +1611,7 @@ union generic_request
struct async_result_request async_result; struct async_result_request async_result;
}; };
#define SERVER_PROTOCOL_VERSION 42 #define SERVER_PROTOCOL_VERSION 43
/* ### make_requests end ### */ /* ### make_requests end ### */
/* Everything above this line is generated automatically by tools/make_requests */ /* Everything above this line is generated automatically by tools/make_requests */
......
...@@ -229,20 +229,18 @@ void PROCESS_CallUserSignalProc( UINT uCode, HMODULE hModule ) ...@@ -229,20 +229,18 @@ void PROCESS_CallUserSignalProc( UINT uCode, HMODULE hModule )
*/ */
static void set_console_handles( HANDLE console ) static void set_console_handles( HANDLE console )
{ {
HANDLE in = FILE_DupUnixHandle( 0, GENERIC_READ ); wine_server_send_fd( 0 );
HANDLE out = FILE_DupUnixHandle( 1, GENERIC_WRITE ); wine_server_send_fd( 1 );
SERVER_START_REQ( set_console_fd ) SERVER_START_REQ( set_console_fd )
{ {
req->handle = console; req->handle = console;
req->handle_in = in; req->fd_in = 0;
req->handle_out = out; req->fd_out = 1;
req->pid = 0; req->pid = 0;
SERVER_CALL(); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
NtClose( in );
NtClose( out );
} }
......
...@@ -477,36 +477,16 @@ DECL_HANDLER(get_console_info) ...@@ -477,36 +477,16 @@ DECL_HANDLER(get_console_info)
/* set a console fd */ /* set a console fd */
DECL_HANDLER(set_console_fd) DECL_HANDLER(set_console_fd)
{ {
struct object *obj_in, *obj_out; int fd_out, fd_in = thread_get_inflight_fd( current, req->fd_in );
int fd_in, fd_out;
if (!(obj_in = get_handle_obj( current->process, req->handle_in, GENERIC_READ, NULL ))) if (req->fd_out == req->fd_in) fd_out = dup( fd_in );
return; else fd_out = thread_get_inflight_fd( current, req->fd_out );
if ((fd_in = dup(obj_in->ops->get_fd( obj_in ))) == -1)
{
release_object( obj_in );
return;
}
release_object( obj_in );
if (!(obj_out = get_handle_obj( current->process, req->handle_out, GENERIC_WRITE, NULL ))) if (fd_in == -1 || fd_out == -1) set_error( STATUS_INVALID_HANDLE );
{ else if (set_console_fd( req->handle, fd_in, fd_out, req->pid )) return;
close( fd_in );
return;
}
if ((fd_out = dup(obj_out->ops->get_fd( obj_out ))) == -1)
{
release_object( obj_out );
close( fd_in );
return;
}
release_object( obj_out );
if (!set_console_fd( req->handle, fd_in, fd_out, req->pid )) if (fd_in != -1) close( fd_in );
{ if (fd_out != -1) close( fd_out );
close( fd_out );
close( fd_in );
}
} }
/* get a console mode (input or output) */ /* get a console mode (input or output) */
......
...@@ -869,8 +869,8 @@ static void dump_open_console_reply( const struct open_console_request *req ) ...@@ -869,8 +869,8 @@ static void dump_open_console_reply( const struct open_console_request *req )
static void dump_set_console_fd_request( const struct set_console_fd_request *req ) static void dump_set_console_fd_request( const struct set_console_fd_request *req )
{ {
fprintf( stderr, " handle=%d,", req->handle ); fprintf( stderr, " handle=%d,", req->handle );
fprintf( stderr, " handle_in=%d,", req->handle_in ); fprintf( stderr, " fd_in=%d,", req->fd_in );
fprintf( stderr, " handle_out=%d,", req->handle_out ); fprintf( stderr, " fd_out=%d,", req->fd_out );
fprintf( stderr, " pid=%d", req->pid ); fprintf( stderr, " pid=%d", req->pid );
} }
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "wine/keyboard16.h" #include "wine/keyboard16.h"
#include "thread.h" #include "thread.h"
#include "file.h"
#include "winerror.h" #include "winerror.h"
#include "wincon.h" #include "wincon.h"
#include "heap.h" #include "heap.h"
...@@ -580,7 +579,6 @@ static BOOL CONSOLE_make_complex(HANDLE handle) ...@@ -580,7 +579,6 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
char buf[256]; char buf[256];
char c = '\0'; char c = '\0';
int i,xpid,master,slave; int i,xpid,master,slave;
HANDLE pty_handle;
if (CONSOLE_GetPid( handle )) return TRUE; /* already complex */ if (CONSOLE_GetPid( handle )) return TRUE; /* already complex */
...@@ -605,36 +603,37 @@ static BOOL CONSOLE_make_complex(HANDLE handle) ...@@ -605,36 +603,37 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
ERR("error creating AllocConsole xterm\n"); ERR("error creating AllocConsole xterm\n");
exit(1); exit(1);
} }
pty_handle = FILE_DupUnixHandle( slave, GENERIC_READ | GENERIC_WRITE );
close( master ); close( master );
close( slave );
if (!pty_handle) return FALSE;
/* most xterms like to print their window ID when used with -S; /* most xterms like to print their window ID when used with -S;
* read it and continue before the user has a chance... * read it and continue before the user has a chance...
*/ */
for (i = 0; i < 10000; i++) for (i = 0; i < 10000; i++)
{ {
BOOL ok = ReadFile( pty_handle, &c, 1, NULL, NULL ); if (read( slave, &c, 1 ) == 1)
if (!ok && !c) usleep(100); /* wait for xterm to be created */ {
else if (c == '\n') break; if (c == '\n') break;
}
else usleep(100); /* wait for xterm to be created */
} }
if (i == 10000) if (i == 10000)
{ {
ERR("can't read xterm WID\n"); ERR("can't read xterm WID\n");
CloseHandle( pty_handle ); close( slave );
return FALSE; return FALSE;
} }
wine_server_send_fd( slave );
SERVER_START_REQ( set_console_fd ) SERVER_START_REQ( set_console_fd )
{ {
req->handle = handle; req->handle = handle;
req->handle_in = pty_handle; req->fd_in = slave;
req->handle_out = pty_handle; req->fd_out = slave;
req->pid = xpid; req->pid = xpid;
SERVER_CALL(); SERVER_CALL();
close( slave );
} }
SERVER_END_REQ; SERVER_END_REQ;
CloseHandle( pty_handle );
/* enable mouseclicks */ /* enable mouseclicks */
strcpy( buf, "\033[?1002h" ); strcpy( buf, "\033[?1002h" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment