e431827c7c
* cygtls.h (_cygtls::call_signal_handler): Rename from call_signal_handler_now. (_cygtls::push): Make second argument mandatory. (_cygtls::fixup_after_fork): Declare new function. (_cygtls::lock): Ditto. * cygtls.cc (_cygtls::fixup_after_fork): Define new function. * dcrt0.cc (cygwin_finished_initializing): Define as bool. (alloc_stack): Use _tlstop rather than arbitrary variable in probably vain attempt to avoid strange fork problem on CTRL-C. (dll_crt0_0): Remove obsolete winpids::init call. * dll_init.cc (dll_dllcrt0): Detect forkee condition as equivalent to initializing. * winsup.h (cygwin_finished_initializing): Declare as bool. * exceptions.cc (handle_exceptions): Rely on cygwin_finished_initializing to determine how to handle exception during process startup. (_cygtls::call_signal_handler): Rename from call_signal_handler_now. (_cygtls::interrupt_now): Fill in second argument to push. (signal_fixup_after_fork): Eliminate. (setup_handler): Initialize locked to avoid potential inappropriate unlock. Resume thread if it has acquired the stack lock. (ctrl_c_handler): Just exit if ctrl-c is hit before cygiwn has finished initializing. * fork.cc (sync_with_child): Don't call abort since it can cause exit deadlocks. (sync_with_child): Change debugging output slightly. (fork_child): Set cygwin_finished_initializing here. Call _cygtls fork fixup and explicitly call sigproc_init. (fork_parent): Release malloc lock on fork failure. (vfork): Call signal handler via _my_tls. * sigproc.cc (sig_send): Ditto. * syscalls.cc (readv): Ditto. * termios.cc (tcsetattr): Ditto. * wait.cc (wait4): Ditto. * signal.cc (nanosleep): Ditto. (abort): Ditto. (kill_pgrp): Avoid killing self if exiting. * sync.cc (muto::acquire): Remove (temporarily?) ill-advised exiting_thread check. * gendef (_sigfe): Be more agressive in protecting stack pointer from other access by signal thread. (_cygtls::locked): Define new function. (_sigbe): Ditto. (_cygtls::pop): Protect edx. (_cygtls::lock): Use guaranteed method to set eax to 1. (longjmp): Aggressively protect signal stack. * miscfuncs.cc (low_priority_sleep): Reduce "sleep time" for secs == 0. * pinfo.cc (winpids::set): Counterintuitively use malloc's lock to protect simultaneous access to the pids list since there are pathological conditions which can cause malloc to call winpid. (winpids::init): Eliminate. * pinfo.h (winpids::cs): Eliminate declaration. * pinfo.h (winpids::init): Eliminate definition.
111 lines
2.9 KiB
C++
111 lines
2.9 KiB
C++
/* sigproc.h
|
|
|
|
Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004 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. */
|
|
|
|
#ifndef _SIGPROC_H
|
|
#define _SIGPROC_H
|
|
#include <signal.h>
|
|
|
|
#define EXIT_SIGNAL 0x010000
|
|
#define EXIT_REPARENTING 0x020000
|
|
#define EXIT_NOCLOSEALL 0x040000
|
|
|
|
#ifdef NSIG
|
|
enum
|
|
{
|
|
__SIGFLUSH = -(NSIG + 1),
|
|
__SIGSTRACE = -(NSIG + 2),
|
|
__SIGCOMMUNE = -(NSIG + 3),
|
|
__SIGPENDING = -(NSIG + 4),
|
|
__SIGDELETE = -(NSIG + 5),
|
|
__SIGFLUSHFAST = -(NSIG + 6)
|
|
};
|
|
#endif
|
|
|
|
#define SIG_BAD_MASK (1 << (SIGKILL - 1))
|
|
|
|
enum procstuff
|
|
{
|
|
PROC_ADDCHILD = 1, // add a new subprocess to list
|
|
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
|
|
};
|
|
|
|
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;
|
|
|
|
struct sigpacket
|
|
{
|
|
siginfo_t si;
|
|
pid_t pid;
|
|
class _cygtls *tls;
|
|
sigset_t *mask;
|
|
union
|
|
{
|
|
HANDLE wakeup;
|
|
struct sigpacket *next;
|
|
};
|
|
int __stdcall process () __attribute__ ((regparm (1)));
|
|
};
|
|
|
|
extern HANDLE signal_arrived;
|
|
extern HANDLE sigCONT;
|
|
|
|
bool __stdcall my_parent_is_alive ();
|
|
void __stdcall sig_dispatch_pending (bool fast = false);
|
|
#ifdef _PINFO_H
|
|
extern "C" void __stdcall set_signal_mask (sigset_t newmask, sigset_t = myself->getsigmask ());
|
|
#endif
|
|
int __stdcall handle_sigprocmask (int sig, const sigset_t *set,
|
|
sigset_t *oldset, sigset_t& opmask)
|
|
__attribute__ ((regparm (3)));
|
|
|
|
extern "C" void __stdcall reset_signal_arrived ();
|
|
extern "C" int __stdcall call_signal_handler_now ();
|
|
void __stdcall sig_clear (int) __attribute__ ((regparm (1)));
|
|
void __stdcall sig_set_pending (int) __attribute__ ((regparm (1)));
|
|
int __stdcall handle_sigsuspend (sigset_t);
|
|
|
|
int __stdcall proc_subproc (DWORD, DWORD) __attribute__ ((regparm (2)));
|
|
|
|
class _pinfo;
|
|
void __stdcall proc_terminate ();
|
|
void __stdcall sigproc_init ();
|
|
void __stdcall subproc_init ();
|
|
void __stdcall sigproc_terminate ();
|
|
bool __stdcall proc_exists (_pinfo *) __attribute__ ((regparm(1)));
|
|
bool __stdcall pid_exists (pid_t) __attribute__ ((regparm(1)));
|
|
int __stdcall sig_send (_pinfo *, siginfo_t&, class _cygtls *tls = NULL) __attribute__ ((regparm (3)));
|
|
int __stdcall sig_send (_pinfo *, int) __attribute__ ((regparm (2)));
|
|
void __stdcall signal_fixup_after_exec ();
|
|
void __stdcall wait_for_sigthread ();
|
|
void __stdcall sigalloc ();
|
|
|
|
int kill_pgrp (pid_t, siginfo_t&);
|
|
int killsys (pid_t, int);
|
|
|
|
extern char myself_nowait_dummy[];
|
|
|
|
extern struct sigaction *global_sigs;
|
|
|
|
#define WAIT_SIG_PRIORITY THREAD_PRIORITY_TIME_CRITICAL
|
|
|
|
#define myself_nowait ((_pinfo *)myself_nowait_dummy)
|
|
#endif /*_SIGPROC_H*/
|