2000-02-17 11:38:33 -08:00
|
|
|
/* sigproc.h
|
|
|
|
|
2002-01-13 12:03:03 -08:00
|
|
|
Copyright 1997, 1998, 2000, 2001, 2002 Red Hat, Inc.
|
2000-02-17 11: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. */
|
|
|
|
|
2002-06-01 23:07:01 -07:00
|
|
|
#ifndef _SIGPROC_H
|
|
|
|
#define _SIGPROC_H
|
2000-09-07 19:56:55 -07:00
|
|
|
#include <signal.h>
|
|
|
|
|
2000-10-27 22:41:44 -07:00
|
|
|
#define EXIT_SIGNAL 0x010000
|
2000-02-17 11:38:33 -08:00
|
|
|
#define EXIT_REPARENTING 0x020000
|
|
|
|
#define EXIT_NOCLOSEALL 0x040000
|
|
|
|
|
|
|
|
enum procstuff
|
|
|
|
{
|
|
|
|
PROC_ADDCHILD = 1, // add a new subprocess to list
|
2001-03-10 15:37:50 -08:00
|
|
|
PROC_CHILDTERMINATED = 2, // a child died
|
|
|
|
PROC_CLEARWAIT = 3, // clear all waits - signal arrived
|
|
|
|
PROC_WAIT = 4, // setup for wait() for subproc
|
|
|
|
PROC_NOTHING = 5 // nothing, really
|
2000-02-17 11: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-16 22:49:51 -07:00
|
|
|
struct sigthread
|
|
|
|
{
|
|
|
|
DWORD id;
|
|
|
|
DWORD frame;
|
2000-11-06 15:12:05 -08:00
|
|
|
CRITICAL_SECTION lock;
|
2001-03-06 22:19:34 -08:00
|
|
|
LONG winapi_lock;
|
2001-04-25 12:11:37 -07:00
|
|
|
BOOL exception;
|
2001-03-06 22:19:34 -08:00
|
|
|
bool get_winapi_lock (int test = 0);
|
|
|
|
void release_winapi_lock ();
|
2000-05-18 14:30:30 -07:00
|
|
|
void init (const char *s);
|
2000-05-16 22:49:51 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class sigframe
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
sigthread *st;
|
2001-10-30 18:58:38 -08:00
|
|
|
inline bool unregister ()
|
2001-03-31 16:06:17 -08:00
|
|
|
{
|
2001-09-11 18:56:32 -07:00
|
|
|
if (!st)
|
|
|
|
return 0;
|
|
|
|
EnterCriticalSection (&st->lock);
|
|
|
|
st->frame = 0;
|
|
|
|
st->exception = 0;
|
|
|
|
st->release_winapi_lock ();
|
|
|
|
LeaveCriticalSection (&st->lock);
|
|
|
|
st = NULL;
|
|
|
|
return 1;
|
2001-03-31 16:06:17 -08:00
|
|
|
}
|
2000-05-16 22:49:51 -07:00
|
|
|
|
|
|
|
public:
|
2001-10-30 18:58:38 -08:00
|
|
|
inline void set (sigthread &t, DWORD ebp, bool is_exception = 0)
|
2000-05-16 22:49:51 -07:00
|
|
|
{
|
2001-03-06 22:19:34 -08:00
|
|
|
DWORD oframe = t.frame;
|
2000-05-16 22:49:51 -07:00
|
|
|
st = &t;
|
2000-09-07 20:12:13 -07:00
|
|
|
t.frame = ebp;
|
2001-04-25 12:11:37 -07:00
|
|
|
t.exception = is_exception;
|
2001-03-06 22:19:34 -08:00
|
|
|
if (!oframe)
|
|
|
|
t.get_winapi_lock ();
|
2000-05-16 22:49:51 -07:00
|
|
|
}
|
2001-10-30 18:58:38 -08:00
|
|
|
inline void init (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0))
|
2000-05-16 22:49:51 -07:00
|
|
|
{
|
2000-05-17 22:05:58 -07:00
|
|
|
if (!t.frame && t.id == GetCurrentThreadId ())
|
2000-10-11 21:38:29 -07:00
|
|
|
set (t, ebp);
|
2000-05-16 22:49:51 -07:00
|
|
|
else
|
|
|
|
st = NULL;
|
|
|
|
}
|
2001-11-02 19:32:27 -08:00
|
|
|
|
|
|
|
sigframe (): st (NULL) {}
|
|
|
|
sigframe (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0)) {init (t, ebp);}
|
2000-05-16 22:49:51 -07:00
|
|
|
~sigframe ()
|
|
|
|
{
|
2001-03-31 16:06:17 -08:00
|
|
|
unregister ();
|
2000-05-16 22:49:51 -07:00
|
|
|
}
|
2001-03-31 16:06:17 -08:00
|
|
|
|
|
|
|
int call_signal_handler ();
|
2000-05-16 22:49:51 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
extern sigthread mainthread;
|
2000-02-17 11:38:33 -08:00
|
|
|
extern HANDLE signal_arrived;
|
2002-08-17 21:13:57 -07:00
|
|
|
extern HANDLE sigCONT;
|
2000-02-17 11:38:33 -08:00
|
|
|
|
|
|
|
BOOL __stdcall my_parent_is_alive ();
|
2000-09-15 19:36:11 -07:00
|
|
|
extern "C" int __stdcall sig_dispatch_pending (int force = FALSE);
|
2000-02-17 11:38:33 -08:00
|
|
|
extern "C" void __stdcall set_process_mask (sigset_t newmask);
|
2001-06-24 14:57:50 -07:00
|
|
|
extern "C" void __stdcall reset_signal_arrived ();
|
2002-01-10 18:24:06 -08:00
|
|
|
int __stdcall sig_handle (int, bool);
|
2000-02-17 11:38:33 -08:00
|
|
|
void __stdcall sig_clear (int);
|
|
|
|
void __stdcall sig_set_pending (int);
|
|
|
|
int __stdcall handle_sigsuspend (sigset_t);
|
|
|
|
|
2000-07-29 09:24:59 -07:00
|
|
|
int __stdcall proc_subproc (DWORD, DWORD);
|
|
|
|
|
2000-08-11 22:35:42 -07:00
|
|
|
class _pinfo;
|
2000-02-17 11:38:33 -08:00
|
|
|
void __stdcall proc_terminate ();
|
|
|
|
void __stdcall sigproc_init ();
|
|
|
|
void __stdcall subproc_init ();
|
|
|
|
void __stdcall sigproc_terminate ();
|
2000-11-11 20:57:41 -08:00
|
|
|
BOOL __stdcall proc_exists (_pinfo *) __attribute__ ((regparm(1)));
|
|
|
|
BOOL __stdcall pid_exists (pid_t) __attribute__ ((regparm(1)));
|
2001-04-27 11:50:59 -07:00
|
|
|
int __stdcall sig_send (_pinfo *, int, DWORD ebp = (DWORD) __builtin_frame_address (0),
|
|
|
|
bool exception = 0) __attribute__ ((regparm(3)));
|
2000-04-07 21:13:12 -07:00
|
|
|
void __stdcall signal_fixup_after_fork ();
|
2003-03-19 17:34:53 -08:00
|
|
|
void __stdcall signal_fixup_after_exec ();
|
2002-08-11 12:19:29 -07:00
|
|
|
void __stdcall wait_for_sigthread ();
|
2000-02-17 11:38:33 -08:00
|
|
|
|
|
|
|
extern char myself_nowait_dummy[];
|
|
|
|
extern char myself_nowait_nonmain_dummy[];
|
|
|
|
|
2002-11-21 20:43:47 -08:00
|
|
|
#define WAIT_SIG_PRIORITY THREAD_PRIORITY_TIME_CRITICAL
|
2000-02-17 11:38:33 -08:00
|
|
|
|
2000-07-29 09:24:59 -07:00
|
|
|
#define myself_nowait ((_pinfo *)myself_nowait_dummy)
|
|
|
|
#define myself_nowait_nonmain ((_pinfo *)myself_nowait_nonmain_dummy)
|
2002-06-01 23:07:01 -07:00
|
|
|
#endif /*_SIGPROC_H*/
|