is a tty associated with the process. Send SIGHUP on CTRL_LOGOFF_EVENT.
* fhandler_tty.cc (fhandler_tty_slave::open): Adjust console open handle
counter regardless of whether this is a pty or tty.
(fhandler_tty_slave::open): Ditto.
(fhandler_tty_slave::dup): Ditto.
(fhandler_tty_common::set_close_on_exec): Ditto.
(fhandler_tty_master::init_console): Decrement console open handle counter
after init since it will now be handled by all tty open.
* syscalls.cc (setsid): Rework debugging output slightly.
(pthread::threads): Instantiate.
(pthread::pthread): Initialize running and suspendend.
Initialize next with NULL.
Add thread to thread list if it is not the null_pthread.
(pthread::~pthread): Remove thread from thread list if it is not the null_pthread.
(pthread::postcreate): Set running flag.
(pthread::exit): Reset running flag.
(pthread::cancel): Try to cancel thread only if still running.
(pthread::_fixup_after_fork): Implement.
(pthread::detach): Check if thread is still running before detach.
* thread.h (pthread::running): New member.
(pthread::next): Ditto.
(pthread::fixup_after_fork): New static method.
(pthread::threads): New static method.
(pthread::_fixup_after_fork): New method.
cygerrno.h.
* include/cygwin/config.h (__DYNAMIC_REENT__): Define.
* include/cygwin/version.h: Bump API minor version.
* cygwin.din: Export __getreent
* cygerrno.h: Include errno.h. Fix places where _impure_ptr is used directly
to store the errno value.
* debug.cc (__set_errno): Ditto.
* errno.cc: Remove _RRENT_ONLY define to get errno.cc compiled.
* signal.cc: Rename _reent_clib to _REENT throughout.
* thread.h (reent_clib): Remove prototype.
* thread.cc (reent_clib): Rename reent_clib to __getreent. Return _impure_ptr
until MTinterface is initialized.
(reent_winsup): Fix a possible SEGV when _r == NULL. Return NULL instead.
* MTinterface::fixup_after_fork: Switch reent back to _impure_ptr to keep
signal handling running when fork is called from a thread other than the
mainthread.
to return 0 if attribute is already initialized back to EBUSY.
(pthread_condattr_init): Ditto.
(pthread_rwlockattr_init): Ditto.
(pthread_mutexattr_init): Ditto.
Fix return code if out of memory.
(pthread_condattr_init): Ditto.
(pthread_rwlockattr_init): Ditto.
(pthread_mutexattr_init): Return 0 if attribute is already initialized.
(MTinterface::Init): Ditto.
* thread.cc (MTinterface::Init): Remove function parameter.
Always initialize reent_key.
(pthread::init_mainthread): Remove function parameter.
(MTinterface::fixup_after_fork): Fix pthread::init_mainthread call.
* dcrt0.cc (dll_crt_0_1) Fix calls to MTinterface::Init and
pthread::init_mainthread.
Call pthread::init_mainthread only when not forked.
* thread.h (pthread_rwlock::release): New method.
* thread.cc (pthread_rwlock::unlock): Use release to signal
waiting threads.
(pthread_rwlock::rdlock_cleanup): Signal waiting threads after a
cancelation.
(pthread_rwlock::wrlock_cleanup): Ditto.
according to the GNU coding style.
* thread.cc: Ditto.
* dcrt0.cc (dll_crt0_1): Rename pthread::initMainThread call to
pthread::init_mainthread.
* pthread.cc (pthead_getsequence_np): Rename pthread::isGoodObject
call to pthread::is_good_object.
declaration.
(List::forEach): Change callback parameter to template class
member functionpointer.
(pthread_keys::fixup_before_fork): Change to inline. Use
List::forEach to fixup keys.
(pthread_keys::fixup_after_fork): Ditto.
(pthread_keys::runAllDestructors): Ditto.
(pthread_key::saveAKey): Remove.
(pthread_key::restoreAKey): Ditto.
(pthread_key::destroyAKey): Ditto.
(pthread_key::run_destructor): Rename to runDestructor.
(pthread_mutex::fixup_after_fork): Change to inline. Use
List::forEach to fixup mutexes after a fork.
(pthread_mutex::FixupAfterFork): New method.
(pthread_mutex::mutexes): New member.
(pthread_cond::fixup_after_fork): Change to inline. Use
List::forEach to fixup conds after a fork.
(pthread_cond::FixupAfterFork): New method.
(pthread_cond::conds): New member.
(pthread_rwlock::fixup_after_fork): Change to inline. Use
List::forEach to fixup rwlocks after a fork.
(pthread_rwlock::FixupAfterFork): New method.
(pthread_rwlock::rwlocks): New member.
(semaphore::fixup_after_fork): Change to inline. Use
List::forEach to fixup mutexes after a fork.
(semaphore::FixupAfterFork): New method.
(semaphore::semaphores): New member.
(MTinterface::mutexs): Remove.
(MTinterface::conds): Ditto.
(MTinterface::rwlocks): Ditto.
(MTinterface::semaphores): Ditto.
(pthread_equal): Add extern "C".
(pthread_mutex_lock): Ditto.
* thread.cc (MTinterface::fixup_after_fork): Change
fixup_after_fork calls for pthread objects.
(semaphore::conds): Instantiate.
(pthread_cond::pthread_cond): Use List::Insert rather than
custom list code.
(pthread_cond::~pthread_cond): Use List::Remove rather than
custom list code.
(pthread_cond::fixup_after_fork): Rename to FixupAfterFork.
(pthread_rwlock::rwlocks): Instantiate.
(pthread_rwlock::pthread_crwlock): Use List::Insert rather than
custom list code.
(pthread_rwlock::~pthread_rwlock): Use List::Remove rather than
custom list code.
(pthread_rwlock::fixup_after_fork): Rename to FixupAfterFork.
(pthread_key::saveAKey): Remove.
(pthread_key::fixup_before_fork): Ditto.
(pthread_key::restoreAKey): Ditto.
(pthread_key::fixup_after_fork): Ditto.
(pthread_key::destroyAKey): Ditto.
(pthread_key::runAllDestructors): Ditto.
(pthread_key::run_destructor): Rename to runDestructor.
(pthread_mutex::mutexes): Instantiate.
(pthread_mutex::pthread_mutex): Use List::Insert rather than
custom list code.
(pthread_mutex::~pthread_mutex): Use List::Remove rather than
custom list code.
(pthread_mutex::fixup_after_fork): Rename to FixupAfterFork.
(semaphore::conds): Instantiate.
(semaphore::semaphore): Use List::Insert rather than custom list
code.
(semaphores::~semaphore): Use List::Remove rather than custom
list code.
(semaphore::fixup_after_fork): Rename to FixupAfterFork.
* dcrt0.cc (dll_crt0_1): Add call to pthread::initMainThread to
initialize mainthread when it is safe to call new.
* init.cc (dll_entry): Change call to store reents in tls key.
* thread.cc (_reent_clib) : Change call to get reents from tls
key.
(_reent_winsup): Ditto.
(MTinterface::Init): Key handling changed. Remove initialization
of member variables.
(MTinterface::fixup_after_fork): Reinitialize mainthread object
after fork. Reset threadount to 1.
(pthread::initMainThread): Create mainthread object dynamically.
and initialize with valid handles.
(pthread::self): Remove calls to create thread objects.
(pthread::setTlsSelfPointer): Change call to store thread self
handle in tls key.
(pthread::getTlsSelfPointer): New static method.
(pthread::exit): Remove setTlsSelfPointer call.
(pthread::initCurrentThread): New method.
(pthread::thread_init_wrapper): Change call to store thread self
handle in tls key.
(pthread::join): Check for a valid joiner.
(pthreadNull::pthreadNull): Mark Null object as detached.
(pthreadNull::exit): Terminate thread via ExitThread.
* thread.h (pthread::initMainThread): Change parameter in function
call.
(pthread::getTlsSelfPointer): New static method.
(pthread::initCurrentThread): New method.
(MTinterface::reent_key): Remove.
(MTinterface::thread_self_dwTlsIndex): Ditto..
(MTinterface::indexallocated): Ditto.
(MTinterface::mainthread): Ditto.
(MTinterface::reent_key): New member.
(MTinterface::thread_self_key): Ditto.
(MTinterface::MTinterface): Initialize all members.
is supposed to be giving up time slice.
* fhandler_console.cc (fhandler_console::read): Switch button 2/3 output escape
sequences to be consistent with xterm.
Rename _pid() to pid() throughout.
* Makefile.in: Compile some objects with -fomit-frame-pointer.
* cygwin.din: Reverse aliasing for _kill.
* syscalls.cc (_getpid_r): New function, implemented for newlib compatibility.
* shared.cc (open_shared): Remove reserving of memory since previous change
eliminate the need for this hack.
* thread.cc (pthread_key::keys): Copy on fork. Add a comment explaining
why.
(pthreadNull::_instance): Copy on fork. Absolutely no state exists
in pthreadNull.
* thread.cc (pthread_mutex::initMutex): Use the wrapper init call.
(pthread_mutex::nativeMutex::init): Implement.
(pthread_mutex::nativeMutex::lock): Ditto.
(pthread_mutex::nativeMutex::unlock): Ditto.
(pthread_mutex::init): Use the wrapper lock and unlockcalls.
* thread.h (pthread_mutex): Move mutexInitializationLock into a
nativeMutex wrapper class.
* pthread.cc (pthread_mutex_init): Use new pthread_mutex::init.
* thread.cc: Change __pthread_mutex_init to pthread_mutex::init
throughout.
(MTinterface::Init): Initialise pthread_mutex support.
(pthread_mutex::mutexInitializationLock): Instantiate.
(pthread_mutex::initMutex): New method.
(__pthread_cond_dowait): Don't dereference untrusted pointers.
Use the new pthread_mutex::init method.
(__pthread_condattr_init): Don't dereference untrusted pointers.
(__pthread_mutex_init): Rename to pthread_mutex::init.
Lock and release mutexInitializationLock to prevent races on
mutex initialisation.
* thread.h (pthread_mutex::initMutex): New method, initialise
pthread_mutex supporting state on process initialisation.
(pthread_mutex::init): Initialise a single mutex.
(pthread_mutex::mutexInitializationLock): A win32 mutex for
syncronising pthread mutex initialisation.
(__pthread_mutex_init): Remove this.
* thread.cc (pthread_key::run_destructor): Run_destructor is not
const as it needs to set the key value.
* thread.h (pthread_key::run_destructor): Ditto.
2002-09-27 Robert Collins <rbtcollins@hotmail.com>
* thread.cc (pthread_key::run_destructor): Follow opengroup algorithm.
I.e. only run the destructor NON-NULL key values, and reset the key
to NULL before running the destructor. Reported by Thomas Pfaff.
already taken care of that.
* fhandler_console.cc (fhandler_console::open): Initialize handles to NULL.
(fhandler_console::close): Ditto. GNUify non-GNU formatted functions calls
throughout.
* pthread.cc: Use class::call for converted pthread and semaphore
calls.
* thread.cc: Convert various __pthread_call and __sem_call to
pthread::call and sem::call throughout.
* pthread.h (__pthread_cancel): Convert to pthread::cancel.
(__pthread_join): Convert to pthread::join.
(__pthread_detach): Convert to pthread::detach.
(__pthread_create): Convert to pthread::create.
(__pthread_once): Convert to pthread::once.
(__pthread_atfork): Convert to pthread::atfork.
(__pthread_suspend): Convert to pthread::suspend.
(__pthread_continue): Convert to pthread::resume.
(__sem_init): Convert to semaphore::init.
(__sem_destroy): Convert to semaphore::destroy.
(__sem_wait): Convert to semaphore::wait.
(__sem_trywait): Convert to semaphore::trywait.
(__sem_post): Convert to semaphore::post.
* thread.cc: Finish the removal of the separate pthread_key
destructor list.
Remove all pthread_key_destructor and pthread_key_destructor_list
references throughout.
(pthread::exit): Call the new pthread_key interface to activate
destructors.
(pthread_key::keys): Change into a list.
(pthread_key::saveAKey): New method, used via forEach.
(pthread_key::restoreAKey): Ditto.
(pthread_key::destroyAKey): Ditto.
(pthread_key::fixup_before_fork): Use the List::forEach functionality.
(pthread_key::fixup_after_fork): Ditto.
(pthread_key::runAllDestructors): New method implementation.
(pthread_key::pthread_key): Use List::Insert rather than custom list
code.
(pthread_key::~pthread_key): Use List::Remove for the same reason.
* thread.h: Remove all pthread_key_destructor and
pthread_key_destructor_list references throughout.
(List): Move the interface above pthread_key in the header.
Use atomic operations during insert and delete.
(List::forEach): A generic interface for doing something on each node.
(pthread_key::runAllDestructors): New method, run all destructors.
(pthread_key::fork_buf): Make private.
(pthread_key::run_destructor): Ditto.
(pthread_key::saveAKey): New method for clearer source.
(pthread_key::restoreAKey): Ditto.
(pthread_key::destroyAKey): Ditto.
(MTinterface::destructors): Remove.
* thread.cc: Partial refactoring of pthread_key destructor
handling. Loosely based on Thomas Pfaff's work.
(pthread_key_destructor_list::Insert): Remove.
(pthread_key_destructor_list::Pop): Remove.
(pthread_key_destructor_list::IterateNull): Call the key's
run_destructor method.
(pthread_key::pthread_key): Initialize new member.
(pthread_key::get): Mark as const for correctness.
(pthread_key::run_destructor): Implement.
* thread.h (pthread_key::get): Mark as const for correctness.
(pthread_key::run_destructor): Declare.
(List): New template class that implements a generic list.
(pthread_key_destructor_list): Inherit from List, and remove
now duplicate functions.