From ab87627c5c4154a3e30108f7e4dd07f5d95c4390 Mon Sep 17 00:00:00 2001 From: ntfreak Date: Thu, 1 Jan 2009 16:06:46 +0000 Subject: - add gdb pipe support to native win32 (--pipe option) git-svn-id: svn://svn.berlios.de/openocd/trunk@1294 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/server/server.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/server/server.c') diff --git a/src/server/server.c b/src/server/server.c index b5b9a205..e97dac9a 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -97,12 +97,11 @@ int add_connection(service_t *service, command_context_t *cmd_ctx) } else if (service->type == CONNECTION_PIPE) { -#ifndef _WIN32 c->fd = service->fd; /* do not check for new connections again on stdin */ service->fd = -1; -#endif + LOG_INFO("accepting '%s' connection from pipe", service->name); if ((retval = service->new_connection(c)) != ERROR_OK) { @@ -223,6 +222,8 @@ int add_service(char *name, enum connection_type type, unsigned short port, int LOG_WARNING("cannot change stdout mode to binary"); if (_setmode(_fileno(stdin), _O_BINARY) < 0) LOG_WARNING("cannot change stdin mode to binary"); + if (_setmode(_fileno(stderr), _O_BINARY) < 0) + LOG_WARNING("cannot change stderr mode to binary"); #else socket_nonblock(c->fd); #endif @@ -365,7 +366,7 @@ int server_loop(command_context_t *command_context) kept_alive(); /* Only while we're sleeping we'll let others run */ - retval = select(fd_max + 1, &read_fds, NULL, NULL, &tv); + retval = socket_select(fd_max + 1, &read_fds, NULL, NULL, &tv); openocd_sleep_postlude(); if (retval == -1) @@ -503,7 +504,7 @@ int server_init(void) WORD wVersionRequested; WSADATA wsaData; - wVersionRequested = MAKEWORD( 2, 2 ); + wVersionRequested = MAKEWORD(2, 2); if (WSAStartup(wVersionRequested, &wsaData) != 0) { @@ -511,7 +512,16 @@ int server_init(void) exit(-1); } - SetConsoleCtrlHandler( ControlHandler, TRUE ); + if (server_use_pipes == 0) + { + /* register ctrl-c handler */ + SetConsoleCtrlHandler(ControlHandler, TRUE); + } + else + { + /* we are using pipes so ignore ctrl-c */ + SetConsoleCtrlHandler(NULL, TRUE); + } signal(SIGINT, sig_handler); signal(SIGTERM, sig_handler); -- cgit v1.2.3