2000-02-17 20:38:33 +01:00
|
|
|
/* sigproc.h
|
|
|
|
|
|
|
|
Copyright 1997, 1998, 2000 Cygnus Solutions.
|
|
|
|
|
|
|
|
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. */
|
|
|
|
|
|
|
|
#define EXIT_SIGNAL 0x010000
|
|
|
|
#define EXIT_REPARENTING 0x020000
|
|
|
|
#define EXIT_NOCLOSEALL 0x040000
|
|
|
|
|
|
|
|
enum procstuff
|
|
|
|
{
|
|
|
|
PROC_ADDCHILD = 1, // add a new subprocess to list
|
|
|
|
PROC_CHILDSTOPPED = 2, // a child stopped
|
|
|
|
PROC_CHILDTERMINATED = 3, // a child died
|
|
|
|
PROC_CLEARWAIT = 4, // clear all waits - signal arrived
|
2000-02-24 07:45:32 +01:00
|
|
|
PROC_WAIT = 5 // setup for wait() for subproc
|
2000-02-17 20:38:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct struct_waitq
|
|
|
|
{
|
|
|
|
int pid;
|
|
|
|
int options;
|
|
|
|
int status;
|
|
|
|
HANDLE ev;
|
|
|
|
void *rusage; /* pointer to potential rusage */
|
|
|
|
struct struct_waitq *next;
|
|
|
|
HANDLE thread_ev;
|
|
|
|
} waitq;
|
|
|
|
|
2000-05-17 07:49:51 +02:00
|
|
|
class muto;
|
|
|
|
|
|
|
|
struct sigthread
|
|
|
|
{
|
|
|
|
DWORD id;
|
|
|
|
DWORD frame;
|
|
|
|
muto *lock;
|
|
|
|
sigthread () : id (0), frame (0), lock (0) {}
|
2000-05-18 23:30:30 +02:00
|
|
|
void init (const char *s);
|
2000-05-17 07:49:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class sigframe
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
sigthread *st;
|
|
|
|
|
|
|
|
public:
|
2000-05-26 08:24:58 +02:00
|
|
|
void set (sigthread &t, int up = 1, DWORD ebp = 0)
|
2000-05-17 07:49:51 +02:00
|
|
|
{
|
|
|
|
t.lock->acquire ();
|
|
|
|
st = &t;
|
2000-05-26 08:24:58 +02:00
|
|
|
if (ebp)
|
|
|
|
t.frame = ebp;
|
|
|
|
else
|
|
|
|
t.frame = (DWORD) (up ? __builtin_frame_address (1) :
|
|
|
|
__builtin_frame_address (0));
|
2000-05-17 07:49:51 +02:00
|
|
|
t.lock->release ();
|
|
|
|
}
|
|
|
|
|
|
|
|
sigframe () {st = NULL;}
|
|
|
|
sigframe (sigthread &t, int up = 1)
|
|
|
|
{
|
2000-05-18 07:05:58 +02:00
|
|
|
if (!t.frame && t.id == GetCurrentThreadId ())
|
2000-05-17 07:49:51 +02:00
|
|
|
set (t, up);
|
|
|
|
else
|
|
|
|
st = NULL;
|
|
|
|
}
|
|
|
|
~sigframe ()
|
|
|
|
{
|
|
|
|
if (st)
|
|
|
|
{
|
|
|
|
st->lock->acquire ();
|
|
|
|
st->frame = 0;
|
|
|
|
st->lock->release ();
|
|
|
|
st = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern sigthread mainthread;
|
2000-02-17 20:38:33 +01:00
|
|
|
extern HANDLE signal_arrived;
|
|
|
|
|
|
|
|
BOOL __stdcall my_parent_is_alive ();
|
|
|
|
extern "C" int __stdcall sig_dispatch_pending (int force = FALSE) __asm__ ("sig_dispatch_pending");
|
|
|
|
extern "C" void __stdcall set_process_mask (sigset_t newmask);
|
2000-05-17 07:49:51 +02:00
|
|
|
int __stdcall sig_handle (int);
|
2000-02-17 20:38:33 +01:00
|
|
|
void __stdcall sig_clear (int);
|
|
|
|
void __stdcall sig_set_pending (int);
|
|
|
|
int __stdcall handle_sigsuspend (sigset_t);
|
|
|
|
|
|
|
|
void __stdcall proc_terminate ();
|
|
|
|
void __stdcall sigproc_init ();
|
|
|
|
void __stdcall subproc_init ();
|
|
|
|
void __stdcall sigproc_terminate ();
|
|
|
|
BOOL __stdcall proc_exists (pinfo *);
|
|
|
|
int __stdcall proc_subproc (DWORD, DWORD);
|
2000-03-09 22:04:05 +01:00
|
|
|
int __stdcall sig_send (pinfo *, int, DWORD ebp = 0);
|
2000-04-08 06:13:12 +02:00
|
|
|
void __stdcall signal_fixup_after_fork ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
extern char myself_nowait_dummy[];
|
|
|
|
extern char myself_nowait_nonmain_dummy[];
|
|
|
|
extern HANDLE hExeced; // Process handle of new window
|
|
|
|
// process created by spawn_guts()
|
|
|
|
|
|
|
|
#define WAIT_SIG_EXITING (WAIT_OBJECT_0 + 1)
|
|
|
|
|
|
|
|
#define allow_sig_dispatch(n) __allow_sig_dispatch (__FILE__, __LINE__, (n))
|
|
|
|
|
|
|
|
#define myself_nowait ((pinfo *)myself_nowait_dummy)
|
|
|
|
#define myself_nowait_nonmain ((pinfo *)myself_nowait_nonmain_dummy)
|
|
|
|
#define proc_register(child) \
|
|
|
|
proc_subproc (PROC_ADDCHILD, (DWORD) (child))
|