4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 12:29:32 +08:00

* pinfo.h (_pinfo::getsig): Remove obsolete function, here and throughout.

* exceptions.cc: Ditto.
* fhandler_termios.cc: Ditto.
* signal.cc: Ditto.
* sigproc.cc: Ditto.
* Makefile.in: Revert previous change which made a cygwin.din newer than a
version.h a warning rather than an error.
This commit is contained in:
Christopher Faylor 2003-11-28 22:13:57 +00:00
parent 74d893b13c
commit 13584f077b
8 changed files with 36 additions and 44 deletions

View File

@ -1,3 +1,15 @@
2003-11-28 Christopher Faylor <cgf@redhat.com>
* pinfo.h (_pinfo::getsig): Remove obsolete function, here and
throughout.
* exceptions.cc: Ditto.
* fhandler_termios.cc: Ditto.
* signal.cc: Ditto.
* sigproc.cc: Ditto.
* Makefile.in: Revert previous change which made a cygwin.din newer
than a version.h a warning rather than an error.
2003-11-28 Christopher Faylor <cgf@redhat.com> 2003-11-28 Christopher Faylor <cgf@redhat.com>
* cygwin.din: Re-add inexplicably missing semaphore/msg functions. * cygwin.din: Re-add inexplicably missing semaphore/msg functions.

View File

@ -375,8 +375,8 @@ $(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
$(AR) rcv $(LIBGMON_A) $(GMON_OFILES) $(AR) rcv $(LIBGMON_A) $(GMON_OFILES)
$(API_VER): $(srcdir)/cygwin.din $(API_VER): $(srcdir)/cygwin.din
@echo Error: Version info is older than DLL API! @echo Error: Version info is older than DLL API!;\
# @false false
version.cc winver.o: winver_stamp version.cc winver.o: winver_stamp
@ : @ :

View File

@ -547,11 +547,11 @@ handle_exceptions (EXCEPTION_RECORD *e0, void *frame, CONTEXT *in0, void *)
debug_printf ("In cygwin_except_handler exc %p at %p sp %p", e.ExceptionCode, in.Eip, in.Esp); debug_printf ("In cygwin_except_handler exc %p at %p sp %p", e.ExceptionCode, in.Eip, in.Esp);
debug_printf ("In cygwin_except_handler sig = %d at %p", sig, in.Eip); debug_printf ("In cygwin_except_handler sig = %d at %p", sig, in.Eip);
if (myself->getsig (sig).sa_mask & SIGTOMASK (sig)) if (global_sigs[sig].sa_mask & SIGTOMASK (sig))
syscall_printf ("signal %d, masked %p", sig, myself->getsig (sig).sa_mask); syscall_printf ("signal %d, masked %p", sig, global_sigs[sig].sa_mask);
debug_printf ("In cygwin_except_handler calling %p", debug_printf ("In cygwin_except_handler calling %p",
myself->getsig (sig).sa_handler); global_sigs[sig].sa_handler);
DWORD *ebp = (DWORD *)in.Esp; DWORD *ebp = (DWORD *)in.Esp;
for (DWORD *bpend = (DWORD *) __builtin_frame_address (0); ebp > bpend; ebp--) for (DWORD *bpend = (DWORD *) __builtin_frame_address (0); ebp > bpend; ebp--)
@ -563,9 +563,9 @@ handle_exceptions (EXCEPTION_RECORD *e0, void *frame, CONTEXT *in0, void *)
if (!myself->progname[0] if (!myself->progname[0]
|| GetCurrentThreadId () == sigtid || GetCurrentThreadId () == sigtid
|| (void *) myself->getsig (sig).sa_handler == (void *) SIG_DFL || (void *) global_sigs[sig].sa_handler == (void *) SIG_DFL
|| (void *) myself->getsig (sig).sa_handler == (void *) SIG_IGN || (void *) global_sigs[sig].sa_handler == (void *) SIG_IGN
|| (void *) myself->getsig (sig).sa_handler == (void *) SIG_ERR) || (void *) global_sigs[sig].sa_handler == (void *) SIG_ERR)
{ {
/* Print the exception to the console */ /* Print the exception to the console */
if (1) if (1)
@ -1010,7 +1010,7 @@ sig_handle (int sig, sigset_t mask, int pid, _threadinfo *tls)
sig_clear (SIGCONT); sig_clear (SIGCONT);
sigproc_printf ("signal %d processing", sig); sigproc_printf ("signal %d processing", sig);
struct sigaction thissig = myself->getsig (sig); struct sigaction thissig = global_sigs[sig];
void *handler; void *handler;
handler = (void *) thissig.sa_handler; handler = (void *) thissig.sa_handler;
@ -1061,7 +1061,7 @@ stop:
if (ISSTATE (myself, PID_STOPPED)) if (ISSTATE (myself, PID_STOPPED))
goto done; goto done;
handler = (void *) sig_handle_tty_stop; handler = (void *) sig_handle_tty_stop;
thissig = myself->getsig (SIGSTOP); thissig = global_sigs[SIGSTOP];
dosig: dosig:
/* Dispatch to the appropriate function. */ /* Dispatch to the appropriate function. */

View File

@ -155,7 +155,7 @@ fhandler_termios::bg_check (int sig)
return with error */ return with error */
int pgid_gone = !pid_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 *) global_sigs[sig].sa_handler == (void *) SIG_IGN) ||
(myself->getsigmask () & SIGTOMASK (sig)); (myself->getsigmask () & SIGTOMASK (sig));
if (pgid_gone) if (pgid_gone)

View File

@ -1,25 +1,10 @@
Copyright 2001 Red Hat Inc., Christopher Faylor Copyright 2001 Red Hat Inc., Christopher Faylor
[this information is currently obsolete -- sorry]
How do signals work? How do signals work?
On process startup, cygwin starts a secondary thread that deals with signals. On process startup, cygwin starts a secondary thread that deals with signals.
This thread contains a loop which blocks waiting for one of three events: This thread contains a loop which blocks waiting for information to show up
on a pipe whose handle (sendsig) is currently stored in _pinfo (this may change).
1) sigcatch_main - a semaphore which, when incremented, indicates that a
signal may be available for the main thread. The caller waits for the
signal to be delivered before returning.
2) sigcatch_nonmain - a semaphore which , when incremented, indicates that
a signal is available for a non-main thread (currently this is not truly
implemented). The caller waits for the signal to be delivered before
returning.
3) sigcatch_nosync - a semaphore which, when incremented, indicates that
a signal may be available for the main thread. The caller does not wait
for the delivery of the signal before returning.
So, the signal handler blocks waiting for one of these three semaphores.
If one of these is activated, then the the signal handler inspects an If one of these is activated, then the the signal handler inspects an
array of integers looking for a non-zero value. The array corresponds array of integers looking for a non-zero value. The array corresponds

View File

@ -104,11 +104,6 @@ public:
inline void set_has_pgid_children (bool val) {has_pgid_children = val;} inline void set_has_pgid_children (bool val) {has_pgid_children = val;}
inline struct sigaction& getsig (int sig)
{
return global_sigs[sig];
}
inline sigset_t& getsigmask () inline sigset_t& getsigmask ()
{ {
return sig_mask; return sig_mask;

View File

@ -56,12 +56,12 @@ signal (int sig, _sig_func_ptr func)
return (_sig_func_ptr) SIG_ERR; return (_sig_func_ptr) SIG_ERR;
} }
prev = myself->getsig (sig).sa_handler; prev = global_sigs[sig].sa_handler;
myself->getsig (sig).sa_handler = func; global_sigs[sig].sa_handler = func;
myself->getsig (sig).sa_mask = 0; global_sigs[sig].sa_mask = 0;
/* SA_RESTART is set to maintain BSD compatible signal behaviour by default. /* SA_RESTART is set to maintain BSD compatible signal behaviour by default.
This is also compatible with the behaviour of signal(2) in Linux. */ This is also compatible with the behaviour of signal(2) in Linux. */
myself->getsig (sig).sa_flags |= SA_RESTART; global_sigs[sig].sa_flags |= SA_RESTART;
set_sigcatchers (prev, func); set_sigcatchers (prev, func);
syscall_printf ("%p = signal (%d, %p)", prev, sig, func); syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
@ -332,7 +332,7 @@ sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact)
return -1; return -1;
} }
struct sigaction oa = myself->getsig (sig); struct sigaction oa = global_sigs[sig];
if (newact) if (newact)
{ {
@ -341,7 +341,7 @@ sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact)
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
} }
myself->getsig (sig) = *newact; global_sigs[sig] = *newact;
if (newact->sa_handler == SIG_IGN) if (newact->sa_handler == SIG_IGN)
sig_clear (sig); sig_clear (sig);
if (newact->sa_handler == SIG_DFL && sig == SIGCHLD) if (newact->sa_handler == SIG_DFL && sig == SIGCHLD)

View File

@ -98,9 +98,9 @@ signal_fixup_after_exec ()
/* Set up child's signal handlers */ /* Set up child's signal handlers */
for (int i = 0; i < NSIG; i++) for (int i = 0; i < NSIG; i++)
{ {
myself->getsig (i).sa_mask = 0; global_sigs[i].sa_mask = 0;
if (myself->getsig (i).sa_handler != SIG_IGN) if (global_sigs[i].sa_handler != SIG_IGN)
myself->getsig (i).sa_handler = SIG_DFL; global_sigs[i].sa_handler = SIG_DFL;
} }
} }
@ -381,7 +381,7 @@ proc_subproc (DWORD what, DWORD val)
remove the process and move on. Otherwise, this process becomes a zombie remove the process and move on. Otherwise, this process becomes a zombie
which must be reaped by a wait() call. */ which must be reaped by a wait() call. */
if (nzombies >= NZOMBIES if (nzombies >= NZOMBIES
|| myself->getsig (SIGCHLD).sa_handler == (void *) SIG_IGN) || global_sigs[SIGCHLD].sa_handler == (void *) SIG_IGN)
{ {
sigproc_printf ("automatically removing zombie %d", thiszombie); sigproc_printf ("automatically removing zombie %d", thiszombie);
remove_zombie (thiszombie); remove_zombie (thiszombie);
@ -616,7 +616,7 @@ sigproc_init ()
} }
memset (w, 0, sizeof *w); // Just to be safe memset (w, 0, sizeof *w); // Just to be safe
myself->getsig (SIGSTOP).sa_flags = SA_RESTART | SA_NODEFER; global_sigs[SIGSTOP].sa_flags = SA_RESTART | SA_NODEFER;
sigproc_printf ("process/signal handling enabled(%x)", myself->process_state); sigproc_printf ("process/signal handling enabled(%x)", myself->process_state);
return; return;
} }