From 488c7683e311fe19bb0c2d03e3a260ac9f95e86b Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 1 Sep 2000 20:54:22 +0000 Subject: [PATCH] * sigproc.cc (proc_info): Rename proc_exists which takes a pid to "pid_exists". * shared.h: Split out "child_info" stuff into a new header file and use where necessary. Declare pid_exists. * child_info.h: New file. --- winsup/cygwin/ChangeLog | 9 +++++ winsup/cygwin/child_info.h | 63 +++++++++++++++++++++++++++++++ winsup/cygwin/dcrt0.cc | 1 + winsup/cygwin/fhandler_termios.cc | 2 +- winsup/cygwin/fork.cc | 1 + winsup/cygwin/shared.h | 51 ------------------------- winsup/cygwin/sigproc.cc | 7 ++-- winsup/cygwin/sigproc.h | 2 +- winsup/cygwin/spawn.cc | 1 + 9 files changed, 81 insertions(+), 56 deletions(-) create mode 100644 winsup/cygwin/child_info.h diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c4b383061..f9e14a7c1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +Fri Sep 1 16:51:26 2000 Christopher Faylor + + * sigproc.cc (proc_info): Rename proc_exists which takes a pid to + "pid_exists". + * shared.h: Split out "child_info" stuff into a new header file and + use where necessary. + Declare pid_exists. + * child_info.h: New file. + Thu Aug 31 16:06:21 2000 Christopher Faylor * errno.cc (set_errno_from_win_error): Actually use arguments to diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h new file mode 100644 index 000000000..7e47b591a --- /dev/null +++ b/winsup/cygwin/child_info.h @@ -0,0 +1,63 @@ +/* childinfo.h: shared child info for cygwin + + Copyright 2000 Red Hat, Inc. + +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. */ + +enum +{ + PROC_MAGIC = 0xaf08f000, + PROC_FORK = PROC_MAGIC + 1, + PROC_EXEC = PROC_MAGIC + 2, + PROC_SPAWN = PROC_MAGIC + 3, + PROC_FORK1 = PROC_MAGIC + 4 // Newer versions provide stack + // location information +}; + +#define PROC_MAGIC_MASK 0xff00f000 +#define PROC_MAGIC_GENERIC 0xaf00f000 +#define PROC_MAGIC_VER_MASK 0x0ff0000 + +#define EXEC_MAGIC_SIZE sizeof(child_info) +class child_info +{ +public: + DWORD zero[1]; // must be zeroed + DWORD cb; // size of this record + DWORD type; // type of record + int cygpid; // cygwin pid of child process + HANDLE subproc_ready; // used for synchronization with parent + HANDLE shared_h; + HANDLE console_h; + HANDLE parent_alive; // handle of thread used to track children + HANDLE myself_pinfo; + ~child_info () + { + if (myself_pinfo) + CloseHandle (myself_pinfo); + } +}; + +class child_info_fork: public child_info +{ +public: + HANDLE forker_finished;// for synchronization with child + DWORD stacksize; // size of parent stack + void *heaptop; + void *heapbase; + void *heapptr; + jmp_buf jmp; // where child will jump to + void *stacktop; // location of top of parent stack + void *stackbottom; // location of bottom of parent stack +}; + +void __stdcall init_child_info (DWORD, child_info *, int, HANDLE); + +extern child_info_fork *child_proc_info; + +/* non-NULL if this process is a child of a cygwin process */ +extern HANDLE parent_alive; diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 40339366c..62a5bca04 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -22,6 +22,7 @@ details. */ #include "pinfo.h" #include "cygerrno.h" #include "fhandler.h" +#include "child_info.h" #include "path.h" #include "dtable.h" #include "thread.h" diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index 49430a005..006da2474 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -132,7 +132,7 @@ fhandler_termios::bg_check (int sig) /* If the process group is no more or if process is ignoring or blocks 'sig', return with error */ - int pgid_gone = !proc_exists (myself->pgid); + int pgid_gone = !pid_exists (myself->pgid); int sigs_ignored = ((void *) myself->getsig(sig).sa_handler == (void *) SIG_IGN) || (myself->getsigmask () & SIGTOMASK (sig)); diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index f93d3a813..981862a83 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -22,6 +22,7 @@ details. */ #include "sync.h" #include "sigproc.h" #include "pinfo.h" +#include "child_info.h" #include "perthread.h" DWORD NO_COPY chunksize = 0; diff --git a/winsup/cygwin/shared.h b/winsup/cygwin/shared.h index 5e3ecd6fe..ed0b83fc3 100644 --- a/winsup/cygwin/shared.h +++ b/winsup/cygwin/shared.h @@ -41,57 +41,6 @@ public: void process_queue (); }; -enum -{ - PROC_MAGIC = 0xaf08f000, - PROC_FORK = PROC_MAGIC + 1, - PROC_EXEC = PROC_MAGIC + 2, - PROC_SPAWN = PROC_MAGIC + 3, - PROC_FORK1 = PROC_MAGIC + 4 // Newer versions provide stack - // location information -}; - -#define PROC_MAGIC_MASK 0xff00f000 -#define PROC_MAGIC_GENERIC 0xaf00f000 -#define PROC_MAGIC_VER_MASK 0x0ff0000 - -#define EXEC_MAGIC_SIZE sizeof(child_info) -class child_info -{ -public: - DWORD zero[1]; // must be zeroed - DWORD cb; // size of this record - DWORD type; // type of record - int cygpid; // cygwin pid of child process - HANDLE subproc_ready; // used for synchronization with parent - HANDLE shared_h; - HANDLE console_h; - HANDLE parent_alive; // handle of thread used to track children - HANDLE myself_pinfo; - ~child_info () - { - if (myself_pinfo) - CloseHandle (myself_pinfo); - } -}; - -class child_info_fork: public child_info -{ -public: - HANDLE forker_finished;// for synchronization with child - DWORD stacksize; // size of parent stack - void *heaptop; - void *heapbase; - void *heapptr; - jmp_buf jmp; // where child will jump to - void *stacktop; // location of top of parent stack - void *stackbottom; // location of bottom of parent stack -}; - -void __stdcall init_child_info (DWORD, child_info *, int, HANDLE); - -extern child_info_fork *child_proc_info; - /* non-NULL if this process is a child of a cygwin process */ extern HANDLE parent_alive; diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index f9f149851..55cde230e 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -20,6 +20,7 @@ details. */ #include "sync.h" #include "sigproc.h" #include "pinfo.h" +#include "child_info.h" #include "perthread.h" extern BOOL allow_ntsec; @@ -185,7 +186,7 @@ proc_can_be_signalled (_pinfo *p) } BOOL __stdcall -proc_exists (pid_t pid) +pid_exists (pid_t pid) { pinfo p (pid); return proc_exists (p); @@ -235,7 +236,7 @@ proc_exists (_pinfo *p) /* If the parent pid does not exist, clean this process out of the pinfo * table. It must have died abnormally. */ - if ((p->pid == p->ppid) || (p->ppid == 1) || !proc_exists (p->ppid)) + if ((p->pid == p->ppid) || (p->ppid == 1) || !pid_exists (p->ppid)) { p->hProcess = NULL; p->process_state = PID_NOT_IN_USE; @@ -390,7 +391,7 @@ proc_subproc (DWORD what, DWORD val) if (wval->pid <= 0) child = NULL; // Not looking for a specific pid - else if (!proc_exists (wval->pid)) /* CGF FIXME -- test that this is one of mine */ + else if (!pid_exists (wval->pid)) /* CGF FIXME -- test that this is one of mine */ goto out; // invalid pid. flag no such child wval->status = 0; // Don't know status yet diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index 9d3b68922..3cce46ee9 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -98,7 +98,7 @@ void __stdcall sigproc_init (); void __stdcall subproc_init (); void __stdcall sigproc_terminate (); BOOL __stdcall proc_exists (_pinfo *); -BOOL __stdcall proc_exists (pid_t); +BOOL __stdcall pid_exists (pid_t); int __stdcall sig_send (_pinfo *, int, DWORD ebp = 0); void __stdcall signal_fixup_after_fork (); diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 63e9a7a93..48218effe 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -26,6 +26,7 @@ details. */ #include "dtable.h" #include "sync.h" #include "sigproc.h" +#include "child_info.h" #include "pinfo.h" #include "perthread.h"