summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <cgf@redhat.com>2004-01-21 04:14:41 +0000
committerChristopher Faylor <cgf@redhat.com>2004-01-21 04:14:41 +0000
commiteaaabbf0111c67e39e98bbb920dfae004fbc44d8 (patch)
treef16b366d55110fb3f941f6ebe412f0868f04ae69
parentc78dc94cc5c939c6a5a6c4dd43e822d54a5f1526 (diff)
downloadgdb-eaaabbf0111c67e39e98bbb920dfae004fbc44d8.tar.gz
* sigproc.cc (pending_signals::save): New function.
(pending_signals::restore): Ditto. (sig_clear): Save/restore current queue pointer. (wait_sig): Delete signals marked as such. * sigproc.h (__SIGDELETE): New enum.
-rw-r--r--winsup/cygwin/ChangeLog254
-rw-r--r--winsup/cygwin/sigproc.cc11
-rw-r--r--winsup/cygwin/sigproc.h95
3 files changed, 357 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
new file mode 100644
index 00000000000..94f4a9df20d
--- /dev/null
+++ b/winsup/cygwin/ChangeLog
@@ -0,0 +1,254 @@
+2004-01-20 Christopher Faylor <cgf@redhat.com>
+
+ * sigproc.cc (pending_signals::save): New function.
+ (pending_signals::restore): Ditto.
+ (sig_clear): Save/restore current queue pointer.
+ (wait_sig): Delete signals marked as such.
+ * sigproc.h (__SIGDELETE): New enum.
+
+2004-01-16 Christopher Faylor <cgf@redhat.com>
+
+ * fhandler_console.cc (fhandler_console::close): Remove obsolete test
+ for vfork_cleanup.
+ * pipe.cc (fhandler_pipe::close): Add comment.
+
+2004-01-16 Christopher Faylor <cgf@redhat.com>
+
+ * cygheap.cc (init_cygheap::close_ctty): Don't NULL ctty if it is still
+ active.
+
+2004-01-16 Christopher Faylor <cgf@redhat.com>
+
+ * dtable.cc (dtable::vfork_parent_restore): Store ctty_on_hold prior to
+ calling close_all_files since it will be zeroed.
+
+2004-01-15 Christopher Faylor <cgf@redhat.com>
+
+ * gentls_offsets: Reinstate unlink of temp files.
+
+2004-01-14 Christopher Faylor <cgf@redhat.com>
+
+ * fhandler_console.cc (fhandler_console::close): Fix debugging output.
+ (fhandler_console::fixup_after_fork): Decrement open_fhs prior to call
+ to fhandler_console::open since this would cause incrementing too much
+ incrementing in child processes. (Probably needs to be handled more
+ elegantly someday)
+ (fhandler_console::fixup_after_exec): Ditto.
+
+2004-01-14 Christopher Faylor <cgf@redhat.com>
+
+ * cygtls.h (_threadinfo::call): Remove regparm declaration to work
+ around compiler bug.
+
+2004-01-13 Christopher Faylor <cgf@redhat.com>
+
+ * autoload.cc (TryEnterCriticalSection): Remove.
+ * dcrt0.cc (dll_crt0_0): Delete inappropriate setting of
+ _my_tls.stackptr to NULL since it has really bad consequences. Make
+ 'si' an automatic variable.
+
+2004-01-13 Christopher Faylor <cgf@redhat.com>
+
+ * cygtls.cc (_threadinfo::init_thread): Correct thinko which caused
+ thread list to be allocated every time.
+ * cygtls.h (CYGTLS_PADSIZE): Define as const int.
+ * sync.h: Make multiple inclusion safe.
+ (muto::next): Eliminate.
+ (muto::exiting_thread): New variable.
+ (muto::set_exiting_thread): New function.
+ (new_muto): Change to use different section for mutos since c++ give
+ inexplicable warning in some cases otherwise.
+ (new_muto1): Ditto.
+ * dcrt0.cc (do_exit): Call muto::set_exiting_thread here.
+ * sync.cc (muto_start): Eliminate.
+ (muto::acquire): Always give exiting thread a lock. Never give thread
+ a lock if exiting.
+ (muto::release): Ditto for releasing.
+ * dtable.cc (dtable::init_lock): Unline function and define here.
+ * dtable.h (lock_cs): Define as a muto since critical sections seem to
+ work oddly on Windows Me.
+ (lock): Accommodate switch to muto.
+ (unlock): Ditto.
+ * exceptions.cc (setup_handler): Don't worry about acquiring mutos
+ since that hasn't mattered for a long time.
+ (signal_exit): Ditto: muto stuff will be handled automatically on exit
+ now.
+
+2004-01-12 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in (DLL_IMPORTS): Link advapi32 to ensure proper DLL
+ initialization.
+ * autoload.cc (RegCloseKey): Arbitrarily choose this function as a
+ "seed" to pull the advapi32 link library in. So, comment out the
+ autoloading.
+ * cygtls.cc (_threadinfo::init_thread): Just clear CYGTLS_PADSIZE.
+ (_threadinfo::remove): Add debugging.
+ (_threadinfo::find_tls): Ditto.
+ * cygtls.h (_threadinfo::padding): Make zero length (for now?).
+ * dcrt0.cc (dll_crt0_0): Move more initialization here from dll_crt0_1.
+ (dll_crt0_1): See above.
+ * dtable.h (dtable::lock): Remove commented out critical section
+ locking.
+ * dtable.h (dtable::init_lock): Remove commented out critical section
+ locking.
+ * dtable.h (dtable::unlock): Remove commented out critical section
+ locking.
+ * exceptions.cc (interruptible): bool'ize.
+ * init.cc (threadfunc_fe): Revert to storing threadfunc at stack
+ bottom.
+ (munge_threadfunc): Ditto. Avoid adding overhead to
+ calibration_thread.
+ (prime_threads): Don't initialize tls stuff.
+ (dll_entry): Make minor change to initialization order.
+ * tlsoffsets.h: Regenerate.
+
+ * sigproc.cc (wait_sig): Add sanity check for end of process thread
+ exit.
+
+ * select.h: Make minor formatting change.
+
+2004-01-10 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in: Add still more -fomit-frame-pointer functions.
+ * dtable.h (dtable::lock): New function.
+ (dtable::unlock): New function.
+ (dtable::init_lock): New function.
+ * cygheap.h (HEAP_TLS): Declare new enum value.
+ (init_cygheap::threadlist): Declare new array.
+ (init_cygheap::sthreads): Declare new variable.
+ (cygheap_fdmanip::~cygheap_fdmanip): Use new dtable lock/unlock
+ functions.
+ (cygheap_fdnew::cygheap_fdnew): Ditto.
+ (cygheap_fdget::cygheap_fdget): Ditto.
+ * dtable.cc (dtable_init): Initialize fdtab critical section.
+ (dtable::fixup_after_fork): Ditto.
+ (dtable::fixup_after_exec): Ditto.
+ (dtable::dup2): Use lock/unlock calls to protect access to fdtab.
+ (dtable::find_fifo): Ditto.
+ (dtable::fixup_before_fork): Ditto.
+ (dtable::fixup_before_exec): Ditto.
+ (dtable::set_file_pointers_for_exec): Ditto.
+ (dtable::vfork_child_dup): Ditto.
+ (dtable::vfork_parent_restore): Ditto.
+ * syscalls.cc (close_all_files): Ditto.
+ * sync.h (muto::acquired): Declare new function.
+ (new_muto1): Declare new macro used to specify name of muto storage.
+ * sync.cc (muto::acquired): Define new function.
+
+ * cygthread.cc (cygthread::stub): Remove signal chain removal call
+ since it is handled during initialization now.
+ * cygthread.cc (cygthread::simplestub): Remove signal chain removal
+ call since it is handled during initialization now.
+ * cygtls.cc (sentry): New class used for locking. Use throughout.
+ (_threadinfo::reset_exception): Don't pop stack.
+ (_threadinfo::find_tls): Move from exceptions.cc.
+ (_threadinfo::init_thread): Initialize array of threads rather than
+ linked list. Take second argument indicating thread function for this
+ thread.
+ (_threadinfo::remove): Search thread array rather than linked list.
+ Use sentry to lock. Only unlock if we got the lock.
+ (_threadinfo::find_tls): Ditto for first two.
+ (handle_threadlist_exception): Handle exceptions when manipulating the
+ thread list in case of premature thread termination.
+ (_threadinfo::init_threadlist_exceptions): Ditto.
+ * cygtls.h (TLS_STACK_SIZE): Decrease size.
+ (_threadinfo::padding): Add element to avoid overwriting lower part of
+ stack.
+ (_threadinfo::remove): Add a "wait" argument to control how long we
+ wait for a lock before removing.
+ * exceptions.cc (init_exception_handler): Make global. Take argument
+ to control exception handler being set.
+ (ctrl_c_handler): Wait forever when removing self from signal chain.
+ (_threadinfo::find_tls): Move to cygtls.cc.
+ (sig_handle): Reorganize detection for thread-specific signals.
+ * heap.cc (heap_init): Rework slightly. Make fatal error more verbose.
+ Remove malloc initialization since it can't happen during dll attach.
+ * init.cc (search_for): Move address to search for on stack here.
+ (threadfunc_ix): Ditto for stack offset. Make shared so that stack
+ walk potentially only has to be done once when cygwin processes are
+ running.
+ (threadfunc_fe): Use standard tls to store thread function (may change
+ back later).
+ (calibration_thread): New function. Potentially called to find
+ threadfunc_ix.
+ (munge_threadfunc): Search for "search_for" value on stack. Output
+ warning when thread func not found on stack. Use standard tls to store
+ thread function.
+ (prime_threads): New function. Called to prime thread front end.
+ (dll_entry): Call dll_crt0_0 here when DLL_PROCESS_ATTACH. Call
+ prime_threads here. Try to remove thread from signal list here.
+ * sigproc.cc (wait_sig): Initialize threadlist exception stuff here.
+ * thread.cc (pthread::exit): Pass argument to signal list remove
+ function.
+ * thread.h: Remove obsolete *ResourceLock defines.
+
+ * tlsoffsets.h: Regenerate.
+
+ * winsup.h (spf): Define temporary debug macro to be deleted later.
+
+ * dcrt0.cc (dll_crt0_0): New function, called during DLL
+ initialization. Mainly consists of code pulled from dll_crt0_1.
+ (dll_crt0_1): See above.
+ (_dll_crt0): Wait for initial calibration thread to complete, if
+ appropriate. Move some stuff to dll_crt0_0.
+ (initialize_main_tls): Accommodate argument change to
+ _thread_info::init_thread.
+ * fork.cc (fork_child): Ditto.
+ (sync_with_child): Fix debug message.
+ * external.cc (cygwin_internal): Remove special considerations for
+ uninitialized dll since initialization happens during dll attach now.
+
+ * dlfcn.cc (dlopen): Remove obsolete *ResourceLock calls.
+ (dlclose): Ditto.
+
+2004-01-05 Christopher Faylor <cgf@redhat.com>
+
+ * cygheap.h (init_cygheap::close_ctty): Declare new function.
+ * cygheap.cc (init_cygheap::close_ctty): Define new function.
+ * syscalls.cc (close_all_files): Use close_ctty.
+ (setsid): Ditto.
+
+ * cygthread.cc (cygthread::stub): Remove exception initialization.
+ * cygthread.cc (cygthread::stub): Remove exception initialization.
+ (cygthread::simplestub): Ditto.
+ * thread.cc (pthread::thread_init_wrapper): Ditto.
+ * cygtls.cc (_last_thread): Make static.
+ (_threadinfo::call2): Initialize exception handler here.
+ (_threadinfo::find_tls): Move here.
+ * exceptions.cc (_threadinfo::find_tls): Move.
+
+ * dcrt0.cc (__api_fatal): Add prefix info to message here rather than
+ including it in every call to function.
+ * winsup.h (api_fatal): Accommodate above change.
+ * debug.cc (add_handle): Don't do anything if cygheap not around.
+ (mark_closed): Ditto.
+
+ * dll_init.cc (dll_list::detach): Fix debug output.
+ * fork.cc (sync_with_child): Ditto.
+ (vfork): Improve debug output.
+ * heap.cc (heap_init): Ditto.
+
+ * exceptions.cc (try_to_debug): Clarify message when debugger attaches.
+
+2004-01-03 Christopher Faylor <cgf@redhat.com>
+
+ * exceptions.cc (_threadinfo::interrupt_now): Avoid double call to
+ sigdelayed.
+ * pinfo.cc (_pinfo::commune_send): Avoid inexplicable test which caused
+ most pids to be shown as "<defunct>" on Win9x.
+
+2004-01-02 Christopher Faylor <cgf@redhat.com>
+
+ * cygheap.h (init_cygheap): Play more vfork shell games and move
+ ctty_on_hold and open_fhs_on_hold (back) here.
+ * dcrt0.cc (_dll_crt0): Just set impure_ptr_ptr here and let later
+ initialization deal with tls.
+ * dtable.cc (dtable::vfork_child_fixup): Move ctty considerations here.
+ (dtable:vfork_parent_restore): And here.
+ * fork.cc (vfork): Reflect change to ctty handling.
+ * perthread.h (vfork_save::fhctty): Eliminate.
+
+ * cygwin.din: Make more exports NOSIGFE that will never be interrupted
+ by a signal.
+
+ * init.cc (dll_entry): Set stackptr to NULL to catch problems earlier.
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index b53aa5f58bf..942373460f1 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -71,6 +71,8 @@ public:
void add (int sig, int pid, _threadinfo *tls);
void del ();
sigelem *next ();
+ sigelem *save () const {return curr;}
+ void restore (sigelem *saved) {curr = saved;}
friend int __stdcall sig_dispatch_pending ();
};
@@ -562,14 +564,16 @@ sig_clear (int target_sig)
sig_send (myself, -target_sig);
else
{
- sigqueue.reset ();
sigelem *q;
+ sigelem *save = sigqueue.save ();
+ sigqueue.reset ();
while ((q = sigqueue.next ()))
if (q->sig == target_sig)
{
- sigqueue.del ();
+ q->sig = __SIGDELETE;
break;
}
+ sigqueue.restore (save);
}
return;
}
@@ -1171,7 +1175,8 @@ wait_sig (VOID *self)
case __SIGFLUSH:
sigqueue.reset ();
while ((q = sigqueue.next ()))
- if (sig_handle (q->sig, *pack.mask, q->pid, q->tls) > 0)
+ if (q->sig == __SIGDELETE
+ || (sig_handle (q->sig, *pack.mask, q->pid, q->tls) > 0))
sigqueue.del ();
break;
default:
diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h
new file mode 100644
index 00000000000..fe9b92b710e
--- /dev/null
+++ b/winsup/cygwin/sigproc.h
@@ -0,0 +1,95 @@
+/* sigproc.h
+
+ Copyright 1997, 1998, 2000, 2001, 2002, 2003 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)
+};
+#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;
+
+extern HANDLE signal_arrived;
+extern HANDLE sigCONT;
+
+bool __stdcall my_parent_is_alive ();
+int __stdcall sig_dispatch_pending ();
+#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 ();
+#ifdef _CYGTLS_H
+int __stdcall sig_handle (int, sigset_t, int, _threadinfo *) __attribute__ ((regparm (3)));
+#endif
+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 *, int, void * = NULL) __attribute__ ((regparm(3)));
+void __stdcall signal_fixup_after_fork ();
+void __stdcall signal_fixup_after_exec ();
+void __stdcall wait_for_sigthread ();
+void __stdcall sigalloc ();
+
+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*/