From 2a6a56c227b8649b3f3f3f6cd1648305e82d3aab Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 18 May 2000 18:32:05 +0000 Subject: [PATCH] * select.cc (thread_pipe): Add paranoid check to ensure thread termination. * external.cc: Eliminate obsolete include. * getopt.c (getopt_long): Fix compiler warning. * shared.h: Moved PID_ definitions to include/sys/cygwin so that they can be used by external programs. * include/sys/cygwin.h: Move external definitions here. Include sys/resource.h to avoid having to do this everywhere. --- winsup/cygwin/ChangeLog | 11 +++++ winsup/cygwin/external.cc | 1 - winsup/cygwin/include/sys/cygwin.h | 69 ++++++++++++++++++++++++++++++ winsup/cygwin/libc/getopt.c | 3 +- winsup/cygwin/select.cc | 6 +++ winsup/cygwin/shared.h | 24 ----------- 6 files changed, 88 insertions(+), 26 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 33cef2ecf..e0b2dfd6a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +Thu May 18 01:28:02 2000 Christopher Faylor + + * select.cc (thread_pipe): Add paranoid check to ensure thread + termination. + * external.cc: Eliminate obsolete include. + * getopt.c (getopt_long): Fix compiler warning. + * shared.h: Moved PID_ definitions to include/sys/cygwin so that they + can be used by external programs. + * include/sys/cygwin.h: Move external definitions here. Include + sys/resource.h to avoid having to do this everywhere. + Thu May 18 01:04:02 2000 Christopher Faylor * sigproc.h (sigframe): Don't set frame info unless tid matches this diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index ccbcb7782..11448fd2f 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -11,7 +11,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ #include "winsup.h" -#include "external.h" static external_pinfo * fillout_pinfo (DWORD pid) diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index 3a3dd6e9b..ff891cc10 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -37,6 +37,75 @@ extern int cygwin32_attach_handle_to_fd (char *, int, HANDLE, int, int); extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, unsigned); #endif +#include + +/* External interface stuff */ + +typedef enum + { + CW_LOCK_PINFO, + CW_UNLOCK_PINFO, + CW_GETTHREADNAME, + CW_GETPINFO, + CW_SETPINFO, + CW_SETTHREADNAME, + CW_GETVERSIONINFO, + CW_READ_V1_MOUNT_TABLES + } cygwin_getinfo_types; + +struct external_pinfo + { + pid_t pid; + pid_t ppid; + HANDLE hProcess; + DWORD dwProcessId, dwSpawnedProcessId; + uid_t uid; + gid_t gid; + pid_t pgid; + pid_t sid; + int ctty; + mode_t umask; + + long start_time; + struct rusage rusage_self; + struct rusage rusage_children; + + char progname[MAX_PATH]; + + DWORD strace_mask; + HANDLE strace_file; + + DWORD process_state; +}; + +DWORD cygwin_internal (cygwin_getinfo_types, ...); + +#define CW_NEXTPID 0x80000000 // or with pid to get next one + +/* Flags associated with process_state */ +enum +{ + PID_NOT_IN_USE = 0x0000, // Free entry. + PID_IN_USE = 0x0001, // Entry in use. + PID_ZOMBIE = 0x0002, // Child exited: no parent wait. + PID_STOPPED = 0x0004, // Waiting for SIGCONT. + PID_TTYIN = 0x0008, // Waiting for terminal input. + PID_TTYOU = 0x0010, // Waiting for terminal output. + PID_ORPHANED = 0x0020, // Member of an orphaned process group. + PID_ACTIVE = 0x0040, // Pid accepts signals. + PID_CYGPARENT = 0x0080, // Set if parent was a cygwin app. + PID_SPLIT_HEAP = 0x0100, // Set if the heap has been split, + // which means we can't fork again. + PID_CLEAR = 0x0200, // Flag that pid should be cleared from parent's + // wait list + PID_SOCKETS_USED = 0x0400, // Set if process uses Winsock. + PID_INITIALIZING = 0x0800, // Set until ready to receive signals. + PID_USETTY = 0x1000, // Setting this enables or disables cygwin's + // tty support. This is inherited by + // all execed or forked processes. + PID_REPARENT = 0x2000 // child has execed +}; + #ifdef __cplusplus }; #endif diff --git a/winsup/cygwin/libc/getopt.c b/winsup/cygwin/libc/getopt.c index a5883f07c..b09e133a6 100644 --- a/winsup/cygwin/libc/getopt.c +++ b/winsup/cygwin/libc/getopt.c @@ -154,7 +154,8 @@ getopt_long(nargc, nargv, options, long_options, index) if ((retval = getopt_internal(nargc, nargv, options)) == -2) { char *current_argv = nargv[optind++] + 2, *has_equal; - int i, current_argv_len, match = -1; + int i, match = -1; + size_t current_argv_len; if (*current_argv == '\0') { return(-1); diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 8d4b34c94..08fba1256 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -505,6 +505,12 @@ thread_pipe (void *arg) goto out; } } + /* Paranoid check */ + if (pi->stop_thread_pipe) + { + select_printf ("stopping from outer loop"); + break; + } if (gotone) break; Sleep (10); diff --git a/winsup/cygwin/shared.h b/winsup/cygwin/shared.h index d4f9c5bfb..ee0aef46b 100644 --- a/winsup/cygwin/shared.h +++ b/winsup/cygwin/shared.h @@ -144,30 +144,6 @@ public: #define ISSTATE(p, f) (!!((p)->process_state & f)) #define NOTSTATE(p, f) (!((p)->process_state & f)) -/* Flags associated with process_state */ -enum -{ - PID_NOT_IN_USE = 0x0000, // Free entry. - PID_IN_USE = 0x0001, // Entry in use. - PID_ZOMBIE = 0x0002, // Child exited: no parent wait. - PID_STOPPED = 0x0004, // Waiting for SIGCONT. - PID_TTYIN = 0x0008, // Waiting for terminal input. - PID_TTYOU = 0x0010, // Waiting for terminal output. - PID_ORPHANED = 0x0020, // Member of an orphaned process group. - PID_ACTIVE = 0x0040, // Pid accepts signals. - PID_CYGPARENT = 0x0080, // Set if parent was a cygwin app. - PID_SPLIT_HEAP = 0x0100, // Set if the heap has been split, - // which means we can't fork again. - PID_CLEAR = 0x0200, // Flag that pid should be cleared from parent's - // wait list - PID_SOCKETS_USED = 0x0400, // Set if process uses Winsock. - PID_INITIALIZING = 0x0800, // Set until ready to receive signals. - PID_USETTY = 0x1000, // Setting this enables or disables cygwin's - // tty support. This is inherited by - // all execed or forked processes. - PID_REPARENT = 0x2000 // child has execed -}; - #define PSIZE 128 class pinfo_list -- 2.43.5