2000-02-18 03:38:33 +08:00
|
|
|
/* sigproc.h
|
|
|
|
|
2001-01-08 12:02:02 +08:00
|
|
|
Copyright 1997, 1998, 2000, 2001 Red Hat, Inc.
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
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. */
|
|
|
|
|
2000-09-08 10:56:55 +08:00
|
|
|
#include <signal.h>
|
|
|
|
|
2000-10-28 13:41:44 +08:00
|
|
|
#define EXIT_SIGNAL 0x010000
|
2000-02-18 03:38:33 +08:00
|
|
|
#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-11-04 13:54:57 +08:00
|
|
|
PROC_WAIT = 5, // setup for wait() for subproc
|
|
|
|
PROC_NOTHING = 6 // nothing, really
|
2000-02-18 03:38:33 +08: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 13:49:51 +08:00
|
|
|
struct sigthread
|
|
|
|
{
|
|
|
|
DWORD id;
|
|
|
|
DWORD frame;
|
2000-11-07 07:12:05 +08:00
|
|
|
CRITICAL_SECTION lock;
|
2000-05-19 05:30:30 +08:00
|
|
|
void init (const char *s);
|
2000-05-17 13:49:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class sigframe
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
sigthread *st;
|
|
|
|
|
|
|
|
public:
|
2000-10-12 12:38:29 +08:00
|
|
|
void set (sigthread &t, DWORD ebp)
|
2000-05-17 13:49:51 +08:00
|
|
|
{
|
|
|
|
st = &t;
|
2000-09-08 11:12:13 +08:00
|
|
|
t.frame = ebp;
|
2000-05-17 13:49:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sigframe () {st = NULL;}
|
2000-10-12 12:38:29 +08:00
|
|
|
sigframe (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0))
|
2000-05-17 13:49:51 +08:00
|
|
|
{
|
2000-05-18 13:05:58 +08:00
|
|
|
if (!t.frame && t.id == GetCurrentThreadId ())
|
2000-10-12 12:38:29 +08:00
|
|
|
set (t, ebp);
|
2000-05-17 13:49:51 +08:00
|
|
|
else
|
|
|
|
st = NULL;
|
|
|
|
}
|
|
|
|
~sigframe ()
|
|
|
|
{
|
|
|
|
if (st)
|
|
|
|
{
|
2000-11-07 07:12:05 +08:00
|
|
|
EnterCriticalSection (&st->lock);
|
2000-05-17 13:49:51 +08:00
|
|
|
st->frame = 0;
|
2000-11-07 07:12:05 +08:00
|
|
|
LeaveCriticalSection (&st->lock);
|
2000-05-17 13:49:51 +08:00
|
|
|
st = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern sigthread mainthread;
|
2000-02-18 03:38:33 +08:00
|
|
|
extern HANDLE signal_arrived;
|
|
|
|
|
|
|
|
BOOL __stdcall my_parent_is_alive ();
|
2000-09-16 10:36:11 +08:00
|
|
|
extern "C" int __stdcall sig_dispatch_pending (int force = FALSE);
|
2000-02-18 03:38:33 +08:00
|
|
|
extern "C" void __stdcall set_process_mask (sigset_t newmask);
|
2000-05-17 13:49:51 +08:00
|
|
|
int __stdcall sig_handle (int);
|
2000-02-18 03:38:33 +08:00
|
|
|
void __stdcall sig_clear (int);
|
|
|
|
void __stdcall sig_set_pending (int);
|
|
|
|
int __stdcall handle_sigsuspend (sigset_t);
|
|
|
|
|
2000-07-30 00:24:59 +08:00
|
|
|
int __stdcall proc_subproc (DWORD, DWORD);
|
|
|
|
|
2000-08-12 13:35:42 +08:00
|
|
|
class _pinfo;
|
2000-02-18 03:38:33 +08:00
|
|
|
void __stdcall proc_terminate ();
|
|
|
|
void __stdcall sigproc_init ();
|
|
|
|
void __stdcall subproc_init ();
|
|
|
|
void __stdcall sigproc_terminate ();
|
2000-11-12 12:57:41 +08:00
|
|
|
BOOL __stdcall proc_exists (_pinfo *) __attribute__ ((regparm(1)));
|
|
|
|
BOOL __stdcall pid_exists (pid_t) __attribute__ ((regparm(1)));
|
|
|
|
int __stdcall sig_send (_pinfo *, int, DWORD ebp = (DWORD) __builtin_frame_address (0)) __attribute__ ((regparm(3)));
|
2000-04-08 12:13:12 +08:00
|
|
|
void __stdcall signal_fixup_after_fork ();
|
2000-10-17 07:55:58 +08:00
|
|
|
void __stdcall signal_fixup_after_exec (bool);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
extern char myself_nowait_dummy[];
|
|
|
|
extern char myself_nowait_nonmain_dummy[];
|
|
|
|
|
|
|
|
#define WAIT_SIG_EXITING (WAIT_OBJECT_0 + 1)
|
|
|
|
|
2000-07-30 00:24:59 +08:00
|
|
|
#define myself_nowait ((_pinfo *)myself_nowait_dummy)
|
|
|
|
#define myself_nowait_nonmain ((_pinfo *)myself_nowait_nonmain_dummy)
|