Commit Graph

271 Commits

Author SHA1 Message Date
Christopher Faylor 1b00002744 * sigproc.cc (no_signals_available): Use existence of signal thread handle to
figure out if we can actually send signals rather than relying on my_sendsig.
(hwait_sig): Make static.
(sigproc_init): Don't set my_sendsig to anything special.  Use new global
static hwait_sig.
(wait_sig): Set hwait_sig to NULL when we are exiting.
2006-01-05 22:38:51 +00:00
Christopher Faylor 4cf4fd4d1c (fix ChangeLog and check in remaining files)
* sigproc.cc (sigproc_init): Move clearing of sync_startup here to lessen the
likelihood of trying to deal with non-cygwin threads in dll_entry.
* fhandler_console: Fix set_console_state_for_spawn comment.
2006-01-05 16:26:22 +00:00
Christopher Faylor 68f62c98f9 add copyright 2006-01-02 02:57:54 +00:00
Christopher Faylor 5d97040501 *** cygwin DLL Changes:
* child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
(child_info::dwProcessId): Delete.
(child_info::straced): New variable.
(child_info::handle_fork): New member function.
* dcrt0.cc (in_forkee): New global variable.
(__cygwin_user_data::forkee): Mark as obsolete.
(do_global_ctors): Use in_forkee rather than user_data->forkee.
(get_cygwin_startup_info): Ditto.  Deal with new straced field to allow strace
to deal with children of attached processes.
(initial_env): Accommodate changes to strace::hello.
(child_info_fork::handle_fork): Rename from plain old 'handle_fork'.  Move
alloc_stack() call elsewhere.
(dll_crt0_0): Fill out more of user_data.  Reference handle_fork via fork_info.
Add some debugging output.
(_dll_crt0): Don't wait for sync thread if sync_startup is invalid.  Zero
sync_startup here.  Call alloc_stack() here, if appropriate.
(dll_crt0_1): Use in_forkee rather than user_data->forkee.
(dll_crt0): Ditto.
* malloc_wrapper.cc (malloc_init): Ditto.
* dll_init.cc (in_forkee): Remove local static version of this variable.
(dll_list::load_after_fork): Don't set in_forkee here.
* external.cc (cygwin_internal): Use strace method rather than accessing field
directly.
* fhandler.cc (fhandler_base::read): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Ditto.
* fork.cc (frok::parent): Invoke strace write_childpid to communicate with
potential strace.
(child_copy): Add more detail to debugging output.
* init.cc (calibration_id): New static variable.
(prime_threads): Set sync_startup to invalid handle if we already know about
thread_func_ix.  Use static calibration_id to hold calibration thread id.
* munge_threadfunc (munge_threadfunc): Don't try to debug if we don't find
threadfunc_ix.
(dll_entry): Avoid calling munge_threadfunc and _cygtls::remove on non-cygwin
threads invoked during process startup.
* pinfo.cc (set_myself): Always call strace.hello here regardless of DEBUGGING.
* sigproc.cc (child_info::child_info): Remove spurious handling of dwProcessId.
Set straced as appropriate.
* spawn.cc (spawn_guts): Rename ciresrv to ch.  Invoke strace write_childpid to
communicate with potential strace.
* strace.cc: Include child_info.h.
(strace::hello): Remove inited test.  Use active() method to test if strace has
been activated.  Handle case where we are started before
(mypid): New function.
(strace::vsprntf): Try to deal more intelligently with case where progname may
not be filled out.  Put pid in parentheses if it is a windows pid rather than a
cygwin pid.  myself has been filled out.
(strace::write_childpid): New function for notifying strace about the creation
of children.
(strace::vprntf): Use strace method rather than accessing field directly.
(strace_printf): Ditto.
(strace::wm): Ditto.
* winsup.h (in_forkee): Declare.
* include/sys/strace.h (strace::write_childpid): Declare new function.
(strace::attached): Define new function.
(strace::active): Ditto.
(strace::active_val): Ditto.
(_STRACE_ON): Delete.
(_STRACE_OFF): Ditto.
(define_strace0): Use strace method rather than accessing field directly.
(strace_printf_wrap): Ditto.
(strace_printf_wrap1): Ditto.

*** cygwin utils changes:
* strace.cc (nprocesses): Make static global.
(quiet): New variable.
(strace_active): Ditto.
(add_child): Increment nprocesses here.  Don't add a child if it is already
added (windows bug?).  Report on child if not quiet.
(get_child): Just return NULL if child not found.
(remove_child): Report on child if not quiet.
(attach_process): Don't complain if given a windows process.  Use windows pid
in error.
(handle_output_debug_string): Issue error if trying to manipulate a process
that we don't know about.  Handle _STRACE_CHILD_PID - attach to reported child
when we get this.
(proc_child): Move nprocesses to file scope.  Report on exceptions.
(longopts): Implement "--quiet".
(opts): Implement "-q".
(main): Manipulate quiet flag.
* utils.sgml (strace): Add words describing '-q'.
2005-12-29 20:46:34 +00:00
Christopher Faylor dcd0465b2b * cygtls.cc (_cygtls::handle_threadlist_exception): Make an error fatal.
* cygtls.h (sockaddr_in): Use header rather than defining our own structure.
* exceptions.cc (_cygtls::interrupt_setup): Use exact contents of sa_mask
rather than assuming tht current sig should be masked, too.
(_cygtls::call_signal_handler): Use more aggressive locking.
* gendef (_sigbe): Wait until later before releasing incyg.
(_sigreturn): Remove more arguments to accommodate quasi-sa_sigaction support.
(_sigdelayed): Push arguments for sa_sigaction.  More work needed here.
* signal.cc (sigaction): Implement SA_NODEFER.
* tlsoffsets.h: Regenerate.

* sigproc.cc (wait_sig): Use default buffer size of Windows 9x complains.
* pinfo.cc (_onreturn::dummy_handle): Remove.
(_onreturn::h): Make this a pointer.
(_onreturn::~_onreturn): Detect whether pointer is NULL rather than value is
NULL.
(_onreturn::_onreturn): Set h to NULL initially.
(_onreturn::no_close_p_handle): Set h to NULL.
(winpids::add): Initialize onreturn with value from p.hProcess immediately.
2005-12-23 22:50:20 +00:00
Christopher Faylor ede284de5f * fork.cc (fork): Honor error return from sig_send. Don't continue with fork
if we couldn't suspend signals.
* sigproc.cc (sig_send): Set sigCONT event when we see __SIGNOHOLD.
(wait_sig): Remove holding_signals.  Create pipe with a buffer which will
theoretically cause blocking if there is nothing reading on the pipe.  Wait for
sigCONT at end of loop when we have a __SIGHOLD.
2005-12-23 01:24:14 +00:00
Christopher Faylor 65438ec635 * fhandler.h (fhandler_pipe::fixup_in_child): Declare new function.
(fhandler_console::invisible_console): Declare new variable.
(fhandler_console::need_invisible): Ditto.
(fhandler_console::has_a): Ditto.
* fhandler_console.cc (set_console_state_for_spawn): Eliminate return value.
Set up an invisible console if necessary prior to spawning.
(fhandler_console::invisible_console): Define.
* fhandler_tty.cc (fhandler_tty_slave::open): Use
fhandler_console::invisible_console to setup an invisible console.
* pipe.cc (fhandler_pipe::fixup_in_child): Define new function from
fixup_after_exec.
(fhandler_pipe::fixup_after_exec): Use fixup_in_child when appropriate.
(fhandler_pipe::fixup_after_fork): Ditto.
* spawn.cc (handle): Reorganize and modernize a little.
(spawn_guts): Rely on set_console_state_for_spawn to set the console into the
right state but don't create the process with "detached" flag if we have no
controlling tty since that confuses 'cmd'.
* dtable.cc (dtable::stdio_init): Don't set console as controlling terminal if
we have an invisible console.
* sigproc.cc (child_info::sync): Use correct name in ForceCloseHandle1.
2005-12-19 04:34:13 +00:00
Christopher Faylor 2c8fd40695 * cygtls.cc (_cygtls::remove): Don't bother if we're exiting.
* sigproc.cc (_cygtls::remove_wq): Ditto.
2005-12-13 16:01:57 +00:00
Christopher Faylor f153e6b280 * cygtls.h (_cygtls::el): New field.
(_cygtls::handle_exceptions): New function declaration.
(_cygtls::handle_threadlist_exception): Ditto.
(_cygtls::init_exception_handler): Ditto.
(_cygtls::init_threadlist_exceptions): Remove arg from declaration.
* cygtls.cc (_cygtls::call2): Don't initialize exceptions here.
(_cygtls::init_thread): Do it here instead and use member function.
(_cygtls::handle_threadlist_exception): Move into _cygtls class.
(_cygtls::init_exception_handler): Ditto.  Rely on existence of 'el' memmber in
_cygtls.
(_cygtls::init_threadlist_exceptions): Ditto.
* dcrt0.cc (dll_crt0_1): Remove exception_list definition and setting since it
now commonly resides in the tls.
* exceptions.cc (init_exception_handler): Move to cygtls.cc.
(init_exceptions): Ditto.
(rtl_unwind): New, safe wrapper function for RtlUnwind.
(_cygtls::handle_exceptions): Move to _cygtls.  Call rtl_unwind to unwind
frames and eliminate copying of structures.  Put address of failing instruction
in si_addr, not the address on the stack.  Return 0 to indicate that we've
handled this exception.
* external.cc (cygwin_internal): Make CW_INIT_EXCEPTIONS a no-op.
* sigproc.cc (wait_sig): Accommodate argument change to
_cygtls::init_threadlist_exceptions.
* tlsoffsets.h: Regenerate.
* include/exceptions.h (exception_list): Add more stuff to the exception list.
Apparently windows needs this?
(init_exceptions): Remove bogus declaration.
* include/cygwin/signal.h (SI_USER): Redefine as zero as per SUSv3.
* thread.cc (pthread_kill): Set si_pid and si_uid.
* timer.cc (timer_thread): Set si_code to SI_TIMER.
2005-12-03 04:23:35 +00:00
Christopher Faylor f02b22dcee * fork.cc (frok::child): Change order of cleanup prior to return.
(fork): Save more of the stack.
* gendef: Fix some comments.
* sigproc.cc (wait_sig): Clarify debug output.
2005-10-29 15:19:34 +00:00
Christopher Faylor 82c925af80 * cygheap.h (cygheap_fdenum::cygheap_fdenum): Record locked state or suffer
deadlocks.
(class locked_process): Move to another header.
* sync.h (lock_process): Define here.
* cygtls.cc (_cygtls::fixup_after_fork): Reset spinning state as well as
stacklock state.
* dcrt0.cc (lock_process::locker): Define.
(dtable::lock_cs): Delete.
* dtable.cc (dtable_init): Eliminate call to init_lock().
(dtable::fixup_after_fork): Ditto.
(dtable::init_lock): Delete definition.
* dtable.h (dtable::init_lock): Delete declaration.
(dtable::lock): Use process lock rather than dtable-specific lock.
(dtable::unlock): Ditto.
* sigproc.cc (sigproc_init): Minor change to debugging output.
* times.cc (utime_worker): Use build_fh_pc rather than reinterpreting the posix
path name again.  Return any error from path_conv immediately.
2005-10-23 23:47:45 +00:00
Christopher Faylor 0cdcb2345a * sigproc.cc (child_info::sync): Move check for !wr_proc_pipe lower.
* spawn.cc (spawn_guts): Correct check for top-level process.
2005-10-19 22:25:46 +00:00
Christopher Faylor b72a5c0767 * cygtls.cc (handle_threadlist_exception): Improve diagnostic output.
* sigproc.cc (child_info::sync): Only clear hProcess when execing.
(wait_sig): Protect readsig handle.
2005-10-19 00:22:08 +00:00
Christopher Faylor a93b4154f1 * sigproc.cc (child_info::sync): Use correct name when closing to prevent
warnings when DEBUGGING.
* spawn.cc (spawn_guts): Set myself.hProcess to pi.hProcess since this may have
been zeroed by the previous sync.
2005-10-18 15:13:13 +00:00
Christopher Faylor 4116609aca * sigproc.cc (child_info::sync): Fix typo which caused hProcess to never be
cleared.  Only clear hProcess when not forking.
2005-10-18 04:20:46 +00:00
Christopher Faylor 267e201dae Change process_lock to lock_process throughout. Change all calls to new
cygthread to handle extra argument, throughout.
* cygthread.h (cygthread::callproc): Declare new method.
(cygthread::cygthread): Add optional length argument to allow copying arguments
to executing thread.
* cygthread.cc (cygthread::callproc): Define new method.
(cygthread::stub): Use callfunc to invoke thread func to allow potentially
allocating stack memory which will be returned.
(cygthread::simplestub): Ditto.
(cygthread::cygthread): Accept arglen argument.  Reset ev here prior to
activating thread.  Wait for ev after activating thread if we're copying
contents to the thread.  Wait until the end before setting h, to allow thread
synchronization.
(cygthread::release): Don't reset ev here.  Rely on that happening the next
time the thread is activated.
* pinfo.h (commune_process): Rename declaration from _pinfo::commune_process.
* pinfo.cc (commune_process): Ditto for definition.  Modify slightly to allow
running as a separate cygthread.
* sigproc.cc (child_info::sync): Always wait for both subproc_ready and any
hProcess if we have a cygwin parent.
(talktome): Change argument to be a pointer to siginfo_t.  Contiguously
allocate whole siginfo_t structure + any needed extra for eventual passing to
commune_process thread.
(wait_sig): Accommodate change in talktome argument.
* pipe.cc (fhandler_pipe::fixup_after_exec): Remove debugging.
2005-10-17 23:27:00 +00:00
Christopher Faylor 0cb6fc5d30 * dcrt0.cc (get_exit_lock): Use myself.lock rather than exit_lock.
* exceptions.cc (exit_lock): Delete.
(events_init): Don't init exit_lock.
* (_pinfo::commune_process): Add per-PICOM debugging.
* sigproc.cc (talktome): Add some temporary debugging statements.
* fhandler_proc.cc (format_proc_cpuinfo): Cosmetic change.
(format_proc_partitions): Ditto.
* syscalls.cc (locked_append): Ditto.
2005-10-02 00:13:41 +00:00
Christopher Faylor 0730fa0763 Change name from commune_recv to commune_process throughout. Change name from
commune_send to commune_request throughout.
* pinfo.h (PICOM_EXTRASTR): New flag.
(PICOM_FIFO): Define with new flag.
(_pinfo::hello_pid): Delete.
(_pinfo::tothem): Delete.
(_pinfo::fromthem): Delete.
(_pinfo::commune_process): Rename from commune_recv.  Add a siginfo_t argument
to declaration.
(_pinfo::commune_request): Rename from commune_send.  Change DWORD to
__uint32_t in declaration.
* pinfo.cc (_pinfo::commune_process): Rename from commune_recv.  Add siginfo_t
argument.  Use information from argument rather than reading from another pipe.
Synchronize with other process's commune event.
(_pinfo::commune_request): Rename from commune_send.  Change DWORD to __uint32
in argument.  Fill out information in new siginfo_t element and rely on
extended operation of sig_send rather than trying to deal with synchronization
issues here.  Use process handle and read pipe information filled out by
sig_send to gather information from the other process.
* sigproc.cc (sig_send): Take special action if "communing" to ensure
synchronization with the other process and to return information about the
other process to the caller.
(talktome): Accept a siginfo_t and handle arguments.  Read additional
information from the signal pipe when _si_commune._si_code has the
PICOM_EXTRASTR flag set.
(wait_sig): Pass the transmitted siginfo_t struct and the pipe handle to
talktome.  Close pipe read handle as soon as possible after we detect that
we're exiting.
2005-09-28 22:56:47 +00:00
Corinna Vinschen dcb091caaf Revert erroneous checkin. 2005-09-28 19:22:25 +00:00
Corinna Vinschen 1204c515fe * fhandler.h (class fhandler_dev_raw): Delete current_position and
eof_detected status flag.  Delete is_eom and is_eof methods.
	Move drive_size, bytes_per_sector, eom_detected status flag, as well
	as the methods read_file, write_file, raw_read and raw_write to ...
	(class fhandler_dev_floppy): ... here. Remove is_eom and is_eof
	methods.  Add dup method.
	* fhandler_floppy.cc (IS_EOM): New macro.
	(fhandler_dev_floppy::is_eom): Remove.
	(fhandler_dev_floppy::is_eof): Remove.
	(fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags.
	(fhandler_dev_floppy::get_drive_info): Only call EX functions on
	systems supporting them and stop suffering strange delays.
	(fhandler_dev_floppy::read_file): Move here, drop setting
	current_position.
	(fhandler_dev_floppy::write_file): Move here, drop setting
	current_position.
	(fhandler_dev_floppy::open): Rearrange comment.
	(fhandler_dev_floppy::dup): New method.
	(fhandler_dev_floppy::get_current_position): New inline method.  Use
	instead of former current_position were appropriate.
	(fhandler_dev_floppy::raw_read): Move here.  Drop EOF handling.
	(fhandler_dev_floppy::raw_write): Move here.  Drop EOF handling.
	(fhandler_dev_floppy::lseek): Remove useless conditions.  Convert
	sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call.
	(fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case
	to here.
	* fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove.
	(fhandler_dev_raw::is_eof): Remove.
	(fhandler_dev_raw::write_file): Remove.
	(fhandler_dev_raw::read_file): Remove.
	(fhandler_dev_raw::raw_read): Remove.
	(fhandler_dev_raw::raw_write): Remove.
	(fhandler_dev_raw::dup): Drop copying removed members.
	(fhandler_dev_raw::ioctl): Drop blocksize testing.
	* wincap.h: Implement has_disk_ex_ioctls throughout.
	* wincap.cc: Ditto.
	(wincap_vista): Preliminary wincaps for Windows Vista/Longhorn.
	(wincapc::init): Add Vista/Longhorn handling.
2005-09-28 19:02:53 +00:00
Christopher Faylor d5f4ee62b7 * exceptions.cc (handle_exceptions): Just si_code to SI_KERNEL first and let it
be overridden.
* exceptions.cc (_cygtls::call_signal_handler): Call signal handler with extra
siginfo_t * and void * parameters when SA_SIGINFO flag is set.
* signal.cc (signal): Clear SA_SIGINFO flag.
(sigqueue): Fix incorrect setting of si_code.
* sigproc.cc (signal_fixup_after_exec): Clear SA_SIGINFO flag when setting
handler to SIG_DFL.
2005-09-26 14:51:48 +00:00
Christopher Faylor 529649f983 * sigproc.cc (wait_sig): Cosmetic change.
* pinfo.cc (pinfo::exit): Don't explicitly remove myself since some other
thread may still be using it.
2005-09-26 01:27:36 +00:00
Christopher Faylor 6f96c53642 * sigproc.cc (sigproc_terminate): More reversion of always-exit-from-sigthread
change.
2005-09-24 19:17:49 +00:00
Christopher Faylor 5e477e9a9b Semi-reversion of always-exit-from-sigthread change of 2005-09-15.
* exceptions.cc (sigpacket::process): Eliminate return after call to reinstated
noreturn function.
(signal_exit): Allow function to exit when a captive process has been
terminated.
* pinfo.cc (pinfo::exit): Enter exit_lock here.  Once again exit here under
control of exit_lock.
* sigproc.cc (sig_send): Don't wait for completion if process is exiting.
Remove special __SIGEXIT accommodations.
(wait_sig): Just exit the thread when a __SIGEXIT has been detected.  Don't
exit the process.
2005-09-23 23:37:52 +00:00
Christopher Faylor 255e7e559e * cygtls.h (struct _cygtls::thread_handle): Remove/revert.
* sigproc.h (struct sipacket::thread_handle): Put thread_handle here.
* sigproc.cc (sigproc_terminate): Move setting of thread_handle...
(sig_send): ...to here.  Put it in packet being sent.  Only close pack.wakeup
when we're waiting for completion.
(wait_sig): Use thread_handle directly from received packet.
2005-09-23 15:18:22 +00:00
Christopher Faylor 936e4018b6 * cygheap.cc (cygheap_fixup_in_child): It's not just for exec.
* cygtls.h (struct _cygtls::thread_handle): New field.
* dcrt0.cc (exit_lock): Remove declaration.
* winsup.h (exit_lock): Add declaration.
* exceptions.cc (sigpacket::process): Properly return after signal_exit.
* pinfo.cc (pinfo::exit): Only exit the process if _my_tls.thread_handle has
not been filled out -- which should be an impossible event.
* sigproc.cc (sigproc_terminate): Fillout _my_tls.thread_handle to provide
something for wait_sig to wait for.  Use the siginfo_t version of sig_send and
fill out the tls argument with _my_tls.
(wait_sig): Wait for the thread specified in pack.tls or (for now) complain
bitterly if it doesn't exit.
2005-09-23 03:35:41 +00:00
Christopher Faylor c529909f45 * dcrt0.cc (do_exit): Only call sigproc_terminate from one location --
pinfo::exit.
* pinfo.cc (pinfo::exit): Move sigproc_terminate later so that signals can be
processed while waiting for hExeced child.
(pinfo::maybe_set_exit_code_from_windows): Set exit code from sigExeced if it
is non-zero.  Set exit_state to ES_EXEC_EXIT prior to waiting for captive
process exit code.
* exceptions.cc (sigExeced): New global variable.
(signal_exit): Remove noreturn attribute from declaration.
(signal_exit): Just terminate captive process and return if hExeced on the
theory that the exit will be subsequently handled in the main thread.
* sigproc.cc (sigproc_terminate): Eliminate test for ES_SIGPROCTERMINATE and
use ES_FINAL instead.
(sig_send): Use no_signals_available instead of duplicate test.
* winsup.h (ES_EXEC_EXIT): New enum.
(ES_SIGPROCTERMINATE): Delete.
2005-09-20 02:06:57 +00:00
Christopher Faylor 1bde6e09a6 * sigproc.cc (talktome): Take siginfo_t argument. Don't scan all pids trying
to find one that's talking to me.  Just use the pid from siginfo_t.
(wait_pid): Pass siginfo_t argument to talktome.
2005-09-19 14:15:06 +00:00
Christopher Faylor 882dfbf776 * pinfo.h (EXITCODE_SET): Move out of range of Windows error.
(EXITCODE_NOSET): Ditto.
* sigproc.cc (no_signals_available): Remove check for hwait_sig.  Just rely on
my_sendsig.  Pass in an argument controlling when it is appropriate to test
EXITCODE_SET.
(proc_can_be_signalled): Remove checks for myself since this function is never
called in that context.
(sigproc_init): Pre-initialize my_sendsig to non-zero so that
proc_can_be_signalled will know that we expect to be signalable soon.
(sig_send): Change debugging output.
2005-09-16 03:16:17 +00:00
Christopher Faylor 150f3bd168 * sigproc.cc (no_signals_available): Return true if sending to self from the
signal thread.
(wait_sig): Correct so that WaitForSingleObject is called when hMainThread is
!= 0, rather than the reverse.
* cygheap.cc (cygheap_fixup_in_child): Clarify potential error message.
* fork.cc (fork_copy): Cosmetic change.
2005-09-16 01:47:09 +00:00
Christopher Faylor a3a9aac72d * sigproc.cc (wait_sig): Reorganize exit case so that ExitProcess is always
called, since that is the intent of sending a __SIGEXIT.  Wait forever for main
thread to go away since, presumably, the main thread told us it was going away.
2005-09-15 16:06:18 +00:00
Christopher Faylor a611ae50d5 * exceptions.cc (sigtid): Remove declaration.
(handle_exceptions): Use _sig_tls rather than sigtid to determine if this is
the signal thread.
(set_signal_mask): Ditto for conditionalized CGF code.
* pinfo.cc (pinfo::exit): Exit the thread if we forcefully terminated the main
thread
* sigproc.cc (sigtid): Delete.
(_sig_tls): Define.
(sig_clear): Use _sig_tls rather than sigtid to determine if this is the signal
thread.
(sig_dispatch_pending): Ditto.
(wait_sig): Set _sig_tls here.
* dcrt0.cc (do_exit): Move sigproc_terminate call later since signal handling
was still needed for subsequent stuff.  Call sigproc_terminate with new
exit_state value.
* pinfo.cc (pinfo::exit): Call sigproc_terminate with new exit_state value.
* sigproc.cc (proc_terminate): Remove unnecessary (void) parameter.
(sigproc_terminate): Ditto.  Add new argument to accept exit state to be set.
(wait_sig): Reorganize __SIGEXIT handling.  Add more debugging output.
* winsup.h (sigproc_terminate): Declare with new exit_state argument.
(exit_states): Reorganize to reflect new exit ordering of sigproc_terminate.
2005-09-14 14:00:07 +00:00
Christopher Faylor 67483cb2cd * dcrt0.cc (do_exit): Rely on sigproc_terminate to set exit_state
appropriately.
* pinfo.cc (pinfo::exit): Always call sigproc_terminate here.  Rely on
sigproc_terminate to signal signal thread to handle eventual process exit.
* sigproc.cc (no_signals_available): Change criteria for determining if this
process can handle signals to itself.
(my_sendsig): New variable.  Copy of my sendsig handle.
(proc_can_be_signalled): Don't send signals if exit code is set.
(sigproc_terminate): Use and set exit_state appropriately to determine when to
do anything.  Send __SIGEXIT to self to control process exit.
(sig_send): Use my_sendsig for sending signals.  Don't call
proc_can_be_signalled for myself since the criteria is now different for
sending signals to myself.
(wait_sig): Copy myself->sendsig to my_sendsig for future use.  Exit signal
loop when __SIGEXIT is received.  Wait for main thread to exit and use its exit
status to actually exit process.
* sigproc.h (__SIGEXIT): New enum.
* dcrt0.cc (alloc_stack): Eliminate superfluous "return;".
* debug.cc (add_handle): Ditto.
* devices.in (device::parse): Ditto.
* dtable.cc (dtable::vfork_parent_restore): Ditto.
(dtable::vfork_child_fixup): Ditto.
* environ.cc (parse_options): Ditto.
* errno.cc (seterrno_from_win_error): Ditto.
* exceptions.cc (sig_handle_tty_stop): Ditto.
(set_signal_mask): Ditto.
* fhandler.cc (fhandler_base::read): Ditto.
(fhandler_base::operator delete): Ditto.
(fhandler_base::seekdir): Ditto.
(fhandler_base::rewinddir): Ditto.
* fhandler_console.cc (fhandler_console::read): Ditto.
(fhandler_console::fixup_after_exec): Ditto.
* sigproc.cc (sigproc_init): Ditto.
(sigproc_terminate): Ditto.

* devices.cc: Regenerate.
2005-09-13 17:08:54 +00:00
Christopher Faylor 00fb79f70e * sigproc.cc (wait_sig): Be more defensive about detecting when we're exiting. 2005-09-13 15:05:53 +00:00
Christopher Faylor be7d909395 Grr. REVERT erroneous checkin. AGAIN. 2005-09-02 17:35:22 +00:00
Christopher Faylor 414808f9e0 * Makefile.in (CXXFLAGS): Use 'override' to correctly set flags to generate
dependencies when invoked from top-level make.
2005-09-02 17:12:37 +00:00
Christopher Faylor b8a66ba2cd revert inexplicable previous checkin 2005-09-02 04:51:09 +00:00
Christopher Faylor 7a1bf10a84 bad_addresses 2005-09-02 04:46:51 +00:00
Christopher Faylor 6a53b21360 * exceptions.cc (set_process_mask_delta): Conditionalize debugging output.
* sigproc.cc (proc_subproc): Make strace output a little more verbose.
2005-08-29 03:12:39 +00:00
Christopher Faylor b9ebff640a * exceptions.cc (handle_sigsuspend): Just sleep forever if called from non-main
thread.
(sigpacket:process): Simplify logic which determines when and how a signal is
masked.  Don't trigger sigwait if there is a signal handler.
* sigproc.cc (wait_sig): Update comment.  Try to process a signal which is in
the queue if it isn't queued for the target thread (this is still not right).
2005-08-25 03:12:48 +00:00
Christopher Faylor e8454a3400 * child_info.h (child_info::sync): Pass pid and HANDLE rather than using pinfo.
(child_info::child_info): Accept an argument controlling whether to create
proc_subproc.
(child_info_spawn::child_info_spawn): Ditto.
* sigproc.cc (child_info::child_info): Ditto.
(child_info_spawn::child_info_spawn): Ditto.
(child_info::sync): Use passed in pid and HANDLE.
* fork.cc (fork_parent): Reflect additional arguments required for
child_info::sync.
* hookapi.cc (hook_or_detect_cygwin): Rename.  Change so that NULL 'fn'
argument just returns "true", indicating that program uses cygwin1.dll.
* spawn.cc (av::win16_exe): New element.
* spawn.cc (av::iscygwin): New element.
(av::fixup): New function.
(spawn_guts): Protect against SEGV.  Use fixup function to detect when it is
safe to wait for a spawned (as opposed to an execed) program.  Reflect changes
in child_info::sync arguments.
* external.cc (cygwin_internal): Reflect function renaming to
hook_or_detect_cygwin.
* cygheap.cc (cygheap_fixup_in_child): Close handle after debug fixup has been
done to prevent false positives in handle collision.
* exceptions.cc (try_to_debug): Notify debugger if already being debugged.
2005-07-17 00:51:03 +00:00
Christopher Faylor 0c55f6ed60 Eliminate (void) cast on standalone function calls throughout. 2005-07-06 20:05:03 +00:00
Christopher Faylor d3b593aa44 * dcrt0.cc (cygwin_exit): Mark as "noreturn".
* sigproc.cc (child_info::ready): Don't signal parent that we are a cygwin
process if we are dynamically loaded.
2005-07-05 20:20:48 +00:00
Christopher Faylor 2f9ae2ed94 Change foo (void) to foo () for all c++ functions throughout. Remove all
fhandler_*::dump functions throughout.
* fhandler.h (fhandler_dev_mem::close): Remove pass-through function in favor
of virtual method.
(handler_dev_raw::close): Ditto.
(fhandler_dev_clipboard::fixup_after_exec): New method.
* fhandler_dev_mem.cc (fhandler_dev_mem::close): Eliminate pass through
* fhandler_dev_raw.cc (fhandler_dev_raw::close): Ditto.
* fhandler_clipboard.cc (fhandler_dev_clipboard::close): Don't go to extra
effort when execing.
(fhandler_dev_clipboard::fixup_after_exec): New function.
* fhandler_console.cc (fhandler_console::close): Don't do "extra stuff" when we
know we're execing.
* fhandler_disk_file.cc (fhandler_disk_file::close): Ditto.
* fhandler_dsp.cc (fhandler_dev_dsp::close): Ditto.
* fhandler_fifo.cc (fhandler_fifo.cc::close): Ditto.  function in favor of base
function.
* fhandler_random.cc (fhandler_dev_random::close): Ditto.
* fhandler_registry.cc (fhandler_registry::close): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::close): Ditto.
* fhandler_virtual.cc (fhandler_virtual::close): Ditto.
* pinfo.cc (proc_waiter): Remove unneeded hExeced declaration.
* sigproc.cc: Ditto.
* winsup.h (hExeced): Define here.
* fhandler_virtual.cc (fhandler_virtual::fixup_after_exec): Just call close()
to reinitialize things to known state.
2005-07-05 03:16:46 +00:00
Christopher Faylor a9c461626e * cygthread.cc (cygthread::detach): Fix debugging output.
* dcrt0.cc (dll_crt0_1): Create signal_arrived early -- before any filename
manipulation.
* sigproc.cc (sigproc_init): Don't create signal_arrived here.
* fork.cc (fork_child): Ditto.
2005-06-15 22:50:31 +00:00
Corinna Vinschen 7311cc1f0c * pinfo.cc (pinfo::init): Define sa_buf as PSECURITY_ATTRIBUTES and
allocate dynamically.
	(pinfo::set_acl): Replace sa_buf by dynamically allocated acl_buf.
	* sec_acl.cc (setacl): Allocate acl dynamically.
	* sec_helper.cc (sec_acl): Add test for alignment of acl when
	DEBUGGING is defined.
	(__sec_user): Same for sa_buf.
	* security.cc (verify_token): Define sd_buf as PSECURITY_DESCRIPTOR
	and allocate dynamically.
	(alloc_sd): Allocate acl dynamically.
	security.h (sec_user_nih): Change first parameter to
	SECURITY_ATTRIBUTES *.
	(sec_user): Ditto.
	* sigproc.cc (wait_sig): Define sa_buf as PSECURITY_ATTRIBUTES and
	allocate dynamically.
	* syscalls.cc (seteuid32): Define dacl_buf as PACL and allocate
	dynamically.
	* uinfo.cc (cygheap_user::init): Define sa_buf as PSECURITY_ATTRIBUTES
	and allocate dynamically.
	* winbase.h (ilockincr): Mark first argument of inline assembly as
	earlyclobber.
	(ilockdecr): Ditto.
2005-06-07 19:31:42 +00:00
Christopher Faylor ce95c6407e * child_info.h (child_info::cygheap_h): Delete.
(child_info::dwProcessId): New field.
* cygheap.cc (init_cheap): Delete.
(dup_now): Ditto.
(cygheap_setup_for_child): Ditto.
(cygheap_setup_for_child_cleanup): Ditto.
(cygheap_fixup_in_child): Simplify.  Use new "child_copy" function to copy heap
from parent.
(_csbrk): Don't attempt allocation if within cygheap section.  Fix so that more
than one allocation will succeed.
(cygheap_init): Reset possibly-nonzero region to zero.
* cygheap.h (cygheap_setup_for_child): Delete declaration.
(cygheap_setup_for_child_cleanup): Ditto.
(cygheap_start): Define as an array.
* cygwin.sc: Modernize.  Remove unneeded sections.  Define cygheap here.
* dcrt0.cc (do_exit): Reflect argument change to close_all_files.
* dtable.cc (dtable::vfork_parent_restore): Ditto.
* dtable.h: Ditto.
* fhandler.h: Ditto.
* fork.cc (fork_copy): Call ReadProcessMemory if there is no thread
(indicating that we're execing).
(fork_child): Don't mess with hParent.
(fork_parent): Remove hParent stuff.  It happens earlier now.  Remove call to
cygheap_setup_for_child* stuff.
(fork): Put child_info_stuff in grouped structure.  Issue error if parent
handle is not set.
(child_copy): New function.
* sigproc.cc (child_info::child_info): Put cygheap settings here.  Set parent
handle.
(child_info::~child_info): Close parent handle if it exists.
* spawn.cc (spawn_guts): Reorganize so that ciresrv is allocated at only the
last minute so that cygheap changes are reflected.  Delete cygheap_setup*
calls.
* syscalls.cc (close_all_files): Add an argument to flag when the fd entry
should be released.
* winsup.h (close_all_files): Add an argument to close_all_files declaration.
Declare child_copy.
2005-06-01 03:46:56 +00:00
Christopher Faylor 05726ddd86 white space and minor comment cleanup. 2005-05-02 03:50:11 +00:00
Christopher Faylor c6cb7f8f01 * sigproc.cc (proc_subproc): Fix handling of waiting for pids with zero value.
* strace.cc (strace::hello): Report parent pid of executing process.
2005-04-20 20:43:36 +00:00
Christopher Faylor 2f1086cbca * sync.h (muto::initforce): Delete flawed implementation.
* pwdgrp.h (pwdgrp::pglock): Make static.
* grp.cc (pwdgrp::pwdgrp): Eliminate use of initforce.
2005-04-05 06:04:57 +00:00