diff options
author | rbcollins <rbcollins> | 2001-09-30 13:56:37 +0000 |
---|---|---|
committer | rbcollins <rbcollins> | 2001-09-30 13:56:37 +0000 |
commit | 6f0cb845d96e289c7a79be32562a605b9a33acbb (patch) | |
tree | fe6f46385718ea9b4af2edc95150c0e34fca20cb /winsup/cygwin/cygserver_process.cc | |
parent | f2d986607e1da33cb0dd6a534fbdb96fe0bd13a6 (diff) | |
download | gdb-6f0cb845d96e289c7a79be32562a605b9a33acbb.tar.gz |
Sun Sep 30 23:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
* Makefile.in: Add cygserver_process.o to cygserver.exe.
* cygserver.cc: Include signal.h and cygwin_version.h.
Define debug_printf as a macro.
Define DEBUG to a value.
(client_request_attach_tty::serve): Add beginning of process cache support.
Change from #ifdef DEBUG to work with new DEBUG style.
(client_request_get_version::serve): Add beginning of process cache support.
(class server_request): New prototype for support of process cache.
(class queue_process_param): New class to allow request loop threading.
(class server_request_queue): Add beginning of process cache support.
Allow request loop threading.
(request_loop): Thread function for request loops.
(server_request_queue::process_requests): Initiator for threaded request loops.
(client_request_shutdown::serve): Add beginning of process cache support.
(server_request::server_request): Ditto.
(server_request::process): Use debug_printf. Add beginning of process cache support.
(server_request_queue::cleanup): Kill off any request loop threads.
(server_request_queue::add): Add beginning of process cache support.
(handle_signal): Trigger a shutdown.
(main): Print out some useful info at startup - version, date time.
Add process cache support.
Spawn a separate thread for the transport request loop, thus allowing concurrent
support for multiple transports.
* cygserver_client.cc (client_request_get_version::serve): Add process cache support.
(client_request_attach_tty::serve): Add process cache support.
(client_request_shutdown::serve): Add process cache support.
* cygsserver_process.cc: New file with the process cache support.
* cygserver_shm.cc: Redefine debug_printf to allow conditional output.
* cygwin.din: Export shmdt().
* shm.cc: Run indent.
Update FIXME's.
(shmdt): New function.
* include/cygwin/cygserver.h (class client_request): Add process cache support.
(class client_request_get_version): Ditto.
(class client_request_shutdown): Ditto.
(class client_request_attach_tty): Ditto.
* include/cygwin/cygserver_process.h: New header for process cache support.
Diffstat (limited to 'winsup/cygwin/cygserver_process.cc')
-rwxr-xr-x | winsup/cygwin/cygserver_process.cc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/winsup/cygwin/cygserver_process.cc b/winsup/cygwin/cygserver_process.cc new file mode 100755 index 00000000000..8ec1c03e3d6 --- /dev/null +++ b/winsup/cygwin/cygserver_process.cc @@ -0,0 +1,72 @@ +/* cygserver_process.cc + + Copyright 2001 Red Hat Inc. + + Written by Robert Collins <rbtcollins@hotmail.com> + + This file is part of Cygwin. + + This software is a copyrighted work licensed under the terms of the + Cygwin license. Please consult the file "CYGWIN_LICENSE" for + details. */ + +#include <errno.h> +#include <stdio.h> +#include <unistd.h> +#include <windows.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> +#include "wincap.h" +#include <cygwin/cygserver_process.h> + +#define debug_printf if (DEBUG) printf +#define DEBUG 1 + +/* process cache */ +process_cache::process_cache () : head (NULL) +{ +} + +class process * +process_cache::process (long pid) +{ + class process_entry *entry = head; + while (entry && entry->process.winpid != pid) + entry = entry->next; + if (!entry) + return NULL; + return &entry->process; +} + +/* process cache entries */ +process_entry::process_entry (long pid) : next (NULL), process (pid) +{ +} + +/* process's */ +process::process (long pid) : winpid (pid) +{ + thehandle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid); + debug_printf ("Got handle %p for new cache process %ld\n", thehandle, pid); +} + +HANDLE +process::handle () +{ + unsigned long exitstate; + bool err = GetExitCodeProcess (thehandle, &exitstate); + if (!err) + { + /* FIXME: */ + thehandle = INVALID_HANDLE_VALUE; + return INVALID_HANDLE_VALUE; + } + if (exitstate != STILL_ACTIVE) + { + /* FIXME: call the cleanup list */ + thehandle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, winpid); + /* FIXME: what if this fails */ + } + return thehandle; +} |