* 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.
This commit is contained in:
Christopher Faylor 2000-09-01 20:54:22 +00:00
parent b13be6f6fb
commit 488c7683e3
9 changed files with 81 additions and 56 deletions

View File

@ -1,3 +1,12 @@
Fri Sep 1 16:51:26 2000 Christopher Faylor <cgf@cygnus.com>
* 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 <cgf@cygnus.com> Thu Aug 31 16:06:21 2000 Christopher Faylor <cgf@cygnus.com>
* errno.cc (set_errno_from_win_error): Actually use arguments to * errno.cc (set_errno_from_win_error): Actually use arguments to

View File

@ -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;

View File

@ -22,6 +22,7 @@ details. */
#include "pinfo.h" #include "pinfo.h"
#include "cygerrno.h" #include "cygerrno.h"
#include "fhandler.h" #include "fhandler.h"
#include "child_info.h"
#include "path.h" #include "path.h"
#include "dtable.h" #include "dtable.h"
#include "thread.h" #include "thread.h"

View File

@ -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', /* If the process group is no more or if process is ignoring or blocks 'sig',
return with error */ return with error */
int pgid_gone = !proc_exists (myself->pgid); int pgid_gone = !pid_exists (myself->pgid);
int sigs_ignored = int sigs_ignored =
((void *) myself->getsig(sig).sa_handler == (void *) SIG_IGN) || ((void *) myself->getsig(sig).sa_handler == (void *) SIG_IGN) ||
(myself->getsigmask () & SIGTOMASK (sig)); (myself->getsigmask () & SIGTOMASK (sig));

View File

@ -22,6 +22,7 @@ details. */
#include "sync.h" #include "sync.h"
#include "sigproc.h" #include "sigproc.h"
#include "pinfo.h" #include "pinfo.h"
#include "child_info.h"
#include "perthread.h" #include "perthread.h"
DWORD NO_COPY chunksize = 0; DWORD NO_COPY chunksize = 0;

View File

@ -41,57 +41,6 @@ public:
void process_queue (); 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 */ /* non-NULL if this process is a child of a cygwin process */
extern HANDLE parent_alive; extern HANDLE parent_alive;

View File

@ -20,6 +20,7 @@ details. */
#include "sync.h" #include "sync.h"
#include "sigproc.h" #include "sigproc.h"
#include "pinfo.h" #include "pinfo.h"
#include "child_info.h"
#include "perthread.h" #include "perthread.h"
extern BOOL allow_ntsec; extern BOOL allow_ntsec;
@ -185,7 +186,7 @@ proc_can_be_signalled (_pinfo *p)
} }
BOOL __stdcall BOOL __stdcall
proc_exists (pid_t pid) pid_exists (pid_t pid)
{ {
pinfo p (pid); pinfo p (pid);
return proc_exists (p); 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 /* If the parent pid does not exist, clean this process out of the pinfo
* table. It must have died abnormally. * 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->hProcess = NULL;
p->process_state = PID_NOT_IN_USE; p->process_state = PID_NOT_IN_USE;
@ -390,7 +391,7 @@ proc_subproc (DWORD what, DWORD val)
if (wval->pid <= 0) if (wval->pid <= 0)
child = NULL; // Not looking for a specific pid 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 goto out; // invalid pid. flag no such child
wval->status = 0; // Don't know status yet wval->status = 0; // Don't know status yet

View File

@ -98,7 +98,7 @@ void __stdcall sigproc_init ();
void __stdcall subproc_init (); void __stdcall subproc_init ();
void __stdcall sigproc_terminate (); void __stdcall sigproc_terminate ();
BOOL __stdcall proc_exists (_pinfo *); 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); int __stdcall sig_send (_pinfo *, int, DWORD ebp = 0);
void __stdcall signal_fixup_after_fork (); void __stdcall signal_fixup_after_fork ();

View File

@ -26,6 +26,7 @@ details. */
#include "dtable.h" #include "dtable.h"
#include "sync.h" #include "sync.h"
#include "sigproc.h" #include "sigproc.h"
#include "child_info.h"
#include "pinfo.h" #include "pinfo.h"
#include "perthread.h" #include "perthread.h"