Commit Graph

5962 Commits

Author SHA1 Message Date
Corinna Vinschen 93c9cdc1b0 * fhandler_raw.cc (fhandler_dev_raw::open): Allow O_EXCL flag, as on
Linux.
2012-10-12 13:59:45 +00:00
Christopher Faylor fe0cb31137 * fhandler_termios.cc (fhandler_termios::line_edit): Don't manipulate
output_mutex on CTRL-S/CTRL-Q to avoid a deadlock.
* fhandler_tty.cc (fhandler_pty_slave::write): Loop when output_stopped is
detected before acquiring output_mutex.  Acquire output_mutex in the loop for
each write.
* tty.h: Remove some obsolete defines.
(tty_min::output_stopped): Make 'bool'.
2012-10-12 01:19:04 +00:00
Corinna Vinschen 9b4d1964a7 * include/cygwin/in.h (struct in_addr): Guard with s_addr to avoid
potential collision with Win32 headers.
2012-10-10 08:36:33 +00:00
Christopher Faylor 64f6e90ef7 * child_info.h (child_info_spawn::has_execed): Remove unneeded synchronization. 2012-10-09 22:07:10 +00:00
Christopher Faylor 9536b817b1 * pinfo.cc: Remove unneeded assert.h. 2012-10-09 15:12:07 +00:00
Christopher Faylor ee705c1dcb * pinfo.cc (pinfo::init): Detect potential race where short block has been
retrieved but PID_EXECED flag is not set.
2012-09-17 20:07:49 +00:00
Christopher Faylor 25e5803d35 * cygthread.cc (cygthread::stub): Remove old, unnecessary, FIXMEd code.
* spawn.cc (child_info_spawn::worker): Avoid calling close_all_files() twice.
2012-09-14 03:32:52 +00:00
Corinna Vinschen 7dc5165954 * pseudo-reloc.cc (auto_protect_for): New function.
(__write_memory): Call auto_protect_for to handle page protection.
	(do_pseudo_reloc): Call auto_protect_for to restore old page protection.
2012-09-02 10:21:34 +00:00
Christopher Faylor 4acb2ffac7 * pinfo.cc (pinfo::init): Remove assertion. 2012-08-26 17:20:30 +00:00
Christopher Faylor 95a94931c8 * pinfo.cc (_pinfo::exists): Don't consider a process with no state to exist. 2012-08-23 14:45:52 +00:00
Christopher Faylor 0b1545eb3a * net.cc (get_adapters_addresses): Drop FIXME part of comment. 2012-08-21 14:41:57 +00:00
Christopher Faylor 39d0171500 * DevNotes: Add entry cgf-000016.
* cygtls.h (_cygtls::push): Inline.
(_cygtls::interrupt_now): Change signal number argument to siginfo_t argument.
(_cygtls::interrupt_setup): Ditto.
(_cygtls::set_siginfo): Delete declaration.
(_cygtls::reset_signal_arrived): Don't reset signal_arrived signal.  Just reset
flag.
* exceptions.cc (_cygtls::interrupt_now): Reflect argument changes.  Pass si to
interrupt_setup.
(_cygtls::interrupt_setup): Reflect argument changes.  Fill out tls infodata
here using passed-in si.  Use si.si_signo instead of sig.
(sigpacket::setup_handler): Move this function into sigpacket class.  Use si
field from the class as appropriate.
(sigpacket::process): Don't call tls->set_siginfo here since setup_handler
could fail.  Eliminate now-unneeded sig argument.
* sigproc.h (sigpacket::setup_handler): Move setup_handler to this class.
2012-08-17 17:29:21 +00:00
Christopher Faylor 23338be7f5 * exceptions.cc (sig_handle_tty_stop): Clear tls sig field.
(sigpacket::process): When continuing, set tls->sig before arming
signal_arrived.
2012-08-17 15:56:05 +00:00
Corinna Vinschen 74d1d0ee80 * fhandler_clipboard.cc (fhandler_dev_clipboard::read): Use
read-ahead buffer for reading Windows clipboard if caller's
	buffer is too small for complete characters.
	* include/limits.h: Remove outdated TODO comment.
2012-08-17 09:23:34 +00:00
Christopher Faylor 00caa48b91 * cygtls.cc (_cygtls::operator HANDLE): Reverse '?' test stupidity. 2012-08-16 19:24:19 +00:00
Christopher Faylor d01efdbe6e * cygheap.cc (init_cygheap::find_tls): Don't consider unitialized threads.
* cygtls.cc (_cygtls::operator HANDLE): Return NULL when tid is not set.
* exceptions.cc (setup_handler): Don't try to suspend a thread if it has no
handle.
2012-08-16 17:11:41 +00:00
Christopher Faylor 4e754267ed fix typo 2012-08-15 19:43:59 +00:00
Christopher Faylor 806e732c01 Rename cancelable_wait -> cygwait throughout.
* DevNotes: Add entry cgf-000015.
* cygwait.h (cygwait): Don't allow an optional PLARGE_INTERGER argument.
2012-08-15 19:07:42 +00:00
Christopher Faylor 879f3ad5ee * cygtls.h (_cygtls::create_signal_arrived): New function.
(_cygtls::set_signal_arrived): Lock creation of signal_arrived.
* cygwait.cc (cancelable_wait): Ignore signal_arrived event if _my_tls 'sig'
element does not exist.
* exceptions.cc (_cygtls::interrupt_setup): Create signal_arrived if recipient
thread has not created it.
2012-08-15 18:50:44 +00:00
Christopher Faylor 588b40e260 * gendef: Tighten up whitespace detection. 2012-08-15 17:29:58 +00:00
Christopher Faylor 0427598641 * gendef: Delete unneeded read from <IN> which ate an arbitrary line from
cygwin.din.
2012-08-15 17:07:47 +00:00
Christopher Faylor d57a4725b1 * exceptions.cc (sigdelayed): Move declaration to sigproc.h.
* sigproc.h (sigdelayed): Make symbol globally available.
* gendef (sigdelayed): Specifically zero incyg and stacklock.
* signal.cc (sigwaitinfo): Lock _my_tls and try harder to clean up signal
information.
2012-08-15 16:35:00 +00:00
Christopher Faylor 0123506d2d * pinfo.cc (_pinfo::exists): Don't consider an execed process to exist. 2012-08-15 14:11:35 +00:00
Corinna Vinschen 25a520c260 * gmon.c (_mcleanup): Fix scope bug when using gmon_out array. 2012-08-14 19:38:43 +00:00
Christopher Faylor 0587c5ef4f * errno.cc (errmap): Keep sorted. 2012-08-14 18:38:22 +00:00
Corinna Vinschen 04ea60440a * thread.cc (semaphore::_fixup_after_fork): Fix Win32 error output in
api_fatal call.
2012-08-14 15:05:13 +00:00
Christopher Faylor fee05a2380 * errno.cc (errmap): Keep sorted. 2012-08-14 14:56:19 +00:00
Corinna Vinschen 3cef8ecc61 * mount.cc (fs_names): Add missing ReFS entry. Change comment.
* mount.h (enum fs_info_type): Add comment.
2012-08-14 09:49:25 +00:00
Christopher Faylor 2134b7a5b0 * errno.cc (errmap): Map ERROR_SXS_CANT_GEN_ACTCTX to ELIBBAD. 2012-08-13 19:33:17 +00:00
Christopher Faylor 52d2371da5 * DevNotes: Add entry cgf-000014.
* cygheap.cc (tls_sentry): Move here, rename from 'sentry' in cygtls.cc
(tls_sentry::lock): Ditto.
(nthreads): Move from cygtls.cc
(THREADLIST_CHUNK): Ditto.
(cygheap_init): Call init_tls_list().
(init_cygheap::init_tls_list): Define new function.
(init_cygheap::add_tls): Ditto.
(init_cygheap::remove_tls): Ditto.
(init_cygheap::find_tls): Ditto.  Semi-resurrect from _cygtls::find_tls.
* cygheap.h (init_cygheap::init_tls_list): Declare new function.
(init_cygheap::add_tls): Ditto.
(init_cygheap::remove_tls): Ditto.
(init_cygheap::find_tls): Ditto.
* cygtls.cc (sentry): Delete.
(sentry::lock): Ditto.
(nthreads): Ditto.
(THREADLIST_CHUNK): Ditto.
(_cygtls::init): Delete definition.
(_cygtls::init_thread): Call cygheap->add_tls() to add thread to global list.
(_cygtls::remove): cygheap->remove_tls() to remove thread from global list.
* cygtls.h (_cygtls::init): Delete declaration.
* dcrt0.cc (dll_crt0_0): Delete call to _cygtls::init().
* exceptions.cc (sigpacket::process): When no thread is specified, try to find
one via cygheap->find_tls.
2012-08-09 19:58:53 +00:00
Corinna Vinschen 34a4d873ad * include/sys/wait.h (_wait): Define when building newlib. 2012-08-08 09:39:36 +00:00
Christopher Faylor f79b8c456f * signal.cc (sigwaitinfo): Change cw_sig to the correct cw_sig_eintr. 2012-08-07 04:25:05 +00:00
Christopher Faylor 45cb627406 * exceptions.cc (sigdelayed): Simplify declaration.
(_cygtls::call_signal_handler): Fix test for when to pop signal stack.  Only do
it exactly when what is on the stack is a no-op.
2012-08-03 15:38:59 +00:00
Christopher Faylor 4485a26eff * spawn.cc (child_info_spawn::worker): Put back a minor variation of Corinna's
test for detecting a background process when starting a non-cygwin process.
2012-08-03 14:48:59 +00:00
Corinna Vinschen 458e15e7d7 * include/cygwin/socket.h (MSG_BCAST): Define.
(MSG_MCAST): Define.
2012-08-01 18:56:45 +00:00
Corinna Vinschen e665b0aab2 * fhandler.h (fhandler_socket::recv_internal): Add bool parameter.
Add regparm attribute.
	* fhandler_socket.cc (fhandler_socket::read): Call recv_internal with
	second parameter set to false.
	(fhandler_socket::readv): Ditto.
	(fhandler_socket::recvfrom): Ditto.
	(fhandler_socket::recv_internal): Convert use_recvmsg from local
	variable to parameter.  Use as request for using WSARecvMsg.  Only
	fail if WSARecvMsg can't be loaded and wsamsg->Control.len > 0,
	otherwise use WSARecv{From}.  Restrict dwFlags to MSG_PEEK when using
	WSARecvMsg.
	(fhandler_socket::recvmsg): Prefer using WSARecvMsg.  Change priority
	of tests for not using WSARecvMsg.  Call recv_internal with second
	parameter set accordingly.
2012-08-01 09:00:53 +00:00
Corinna Vinschen 02a2590f08 * Makefile.in: Semi-revert patch from 2012-07-01, assuming the previous
patch to etc::dir_changed fixes the underlying issue.
2012-08-01 08:17:16 +00:00
Corinna Vinschen bc025aada5 * path.cc (etc::dir_changed): Revert muto changes since function is
called under lock condition anyway.
2012-07-31 19:56:32 +00:00
Corinna Vinschen 68e41cfcf4 * path.cc (etc::dir_changed): Change `io' to a static NO_COPY
variable.  Explain why.  Add a muto to guard overwriting the changed_h
	handle by multiple concurrent threads.
	* path.h (class etc): Drop unused changed_h member.
2012-07-31 19:36:16 +00:00
Christopher Faylor 7d8b0c8447 * Makefile.common (CFLAGS_COMMON): Add temporary define to work around w32api
problem.

* cygwin/winlean.h: Define constant which will be needed eventually.  Remove
hack in favor of another hack.
* cygwin/lib/crt0.h: Use "winlean.h".
2012-07-30 04:43:22 +00:00
Christopher Faylor 413ce08289 * winlean.h: Add temporary define.
* winsup.h: Remove ancient debugging defines.
2012-07-30 04:26:05 +00:00
Christopher Faylor d239805457 * cygwait.cc (cancelable_wait): Add some debugging-only output.
* exceptions.cc (sig_handle_tty_stop): Make sure that incyg is cleared when
exiting if we have no parent process.  Only wait for signal_arrived.
(sigpacket::process): Make continue_now a bool.  Delay sending signal_arrived
until the end.  Make code more defensive to avoid calling signal handler when
stopped.  Only set signal_arrived when stopped.
* sigproc.cc (sig_hold): Rename from sigCONT.  Make static.
(sig_send): Accommodate sigCONT -> sig_hold rename.
(wait_sig): Ditto.
* sigproc.h (sigCONT): Delete declaration.
* fhandler_console.cc (fhandler_console::write): Use new '%0c' facility to
print characters.  Change to paranoid to avoid excessive strace output.
* fhandler_tty.cc (fhandler_pty_master::accept_input): Make frequent strace
printf "paranoid" to help cut down on strace output size.
* signal.cc (sigsuspend): Add standard syscall strace output.
(sigpause): Ditto.
(pause): Ditto.
* cygtls.h (_cygtls::reset_signal_arrived): New function.
2012-07-30 03:44:40 +00:00
Christopher Faylor dd06381996 * cygtls.cc (_cygtls::reset_signal_arrived): New function.
(set_signal_arrived::~set_signal_arrived): Use reset_signal_arrived to reset
state.
* exceptions.cc (sig_handle_tty_stop): Use WAIT_SIGNALED rather than assume we
know the return from cancelable_wait.
(_cygtls::interrupt_setup): Modify to allow calling when executing in
non-cygwin code via sigdelayed.  Always reset signal_arrived.
* gendef: Throughout use start_offset rather than the completely wrong
sizeof__cygtls.
(_sigdelayed): Rewrite to avoid duplication when calling the signal handler.
(sigreturn): Delete.
* gentls_offsets: Define start_offset rather than sizeof__cygtls.
* tlsoffsets.h: Regenerate.
2012-07-29 21:43:29 +00:00
Christopher Faylor 7ea2ecec23 * fhandler_termios.cc (fhandler_termios::line_edit): Use special case '%0c'
handling to print non-printable characters using hex notation.
* smallprint.cc (__small_vsprintf): Semi-reimplement printing of non-printable
characters in hex but only when padding is specified.
* dcrt0.cc (dll_crt0_0): Remove tty_list initialization.
* shared.cc (memory_init): Initialize tty_list here.
* path.cc (path_conv::check): Remove unneeded parentheses from if check.
2012-07-29 19:18:05 +00:00
Corinna Vinschen a2b7f56971 * include/inttypes.h: Add x86_64 target considerations throughout.
Define macros in C++ according to C99 requirements.
	* include/stdint.h: Ditto.
2012-07-28 14:21:34 +00:00
Christopher Faylor 8f748bdaca * signal.cc (clock_nanosleep): Force return on signal rather than letting
cancelable_wait loop on signal.
2012-07-25 22:21:17 +00:00
Corinna Vinschen a654829ade * syscalls.cc (enum bin_status): Add dir_not_empty.
(try_to_bin): Call NtQueryInformationFile(FileInternalInformation)
	with exact buffer size.  Explain why.
	Ditto for NtSetInformationFile(FileRenameInformation).
	Handle race-condition which might lead to renaming a non-empty
	directory.
	(unlink_nt): Rearrange and partially rephrase comments related to the
	STATUS_SHARING_VIOLATION case.  Fix condition under which a dir is
	tested for being non-empty.  Handle dir_not_empty return code from
	try_to_bin.  Gracefully handle disappearing directory in rm -r
	workaround.  Fix typo in comment.
2012-07-25 12:32:37 +00:00
Corinna Vinschen 67d71dbf10 * wincap.cc (wincapc::init): Drop memset call since it can result in
a race condition.  Drop all considerations for pre-Windows 2000 systems
	since Cygwin won't start on them anyway.
2012-07-24 13:56:14 +00:00
Christopher Faylor 44aa2292b7 Change "set_thread_waiting" to "set_signal_arrived" throughout. 2012-07-23 04:36:48 +00:00
Christopher Faylor 962f9a2ccc * DevNotes: Add entry cgf-000013.
* cygserver_ipc.h (ipc_set_proc_info): Use _cygtls::ipc_set_proc_info to set
per-thread signal arrived value.
* cygthread.cc (cygthread::detach): Use per-thread signal_arrived via
set_thread_waiting.
* fork.cc (_cygtls::fixup_after_fork): Clear signal_arrived.
(_cygtls::remove): Close any signal_arrived handle when thread exists.
(_cygtls::find_tls): Remove unneeded function.
* cygtls.h: Update copyright.
(class _cygtls): Reorganize to help avoid rebuilding newlib when structure
changes.
(_cygtls::event): Delete.
(_cygtls::threadkill): Ditto.
(_cygtls::signal_waiting): Declare new bool.
(_cygtls::find_tls): Delete declaration.
(_cygtls::set_threadkill): Ditto.
(_cygtls::reset_threadkill): Ditto.
(_cygtls::set_signal_arrived): Declare new function.
(class set_thread_waiting): Declare new class.
* cygwait.cc (cw_nowait_storage): Define.
(cygwait): Set per-thread signal_arrived via set_thread_waiting.  Don't
special-case _main_tls.
* cygwait.h (cw_nowait): Define.
(cw_infinite): Ditto.
(cygwait): Redefine pathological wait-only case.
* dcrt0.cc (dll_crt0_0): Remove call to now-defunct events_init().
(dll_crt0_1): Remove call to now-defunct create_signal_arrived().
* exceptions.cc: Reflect set_signal_mask() argument reordering throughout.
Remove signal mask synchronization throughout.
(events_init): Delete definition.
(mask_sync): Delete now-unneeded mask synchronization.
(set_signal_mask): Reverse order of arguments to "standard" to, from layout.
Rename "newmask" argument to "setmask".  Remove debugging.
(sig_handle_tty_stop): Use cancelable_wait rather than WFMO.
(_cygtls::interrupt_setup): Don't treat "threadkill" events specially.
Conditionally set signal_arrived depending on whether the thread has created it
or not.
(sigpacket::process): Reorganize to reflect thread-specific sending of signals
which is more in line with the way it was actually supposed to work.
* fhandler_socket.cc (get_inet_addr): Use cancelable_wait rather than
IsEventSignalled to avoid potential race.
(fhandler_socket::wait_for_events): Set signal_arrived event using
set_thread_waiting().
(fhandler_socket::close): Use cygwait for the case of just waiting 10 ms for a
signal.
* fhandler_tape.cc (fhandler_dev_tape::_lock): Use cancelable_wait rather than
WFMO.  Redo switch/case tests accordingly.
* fhandler_termios.cc (fhandler_termios::bg_check): Use cygwait for case of
just waiting 0 ms for a potential signal.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Use
cancelable_wait rather than WFSO.
* fhandler_windows.cc (fhandler_windows::read): Set per-thread signal_arrived
via set_thread_waiting().
* flock.cc (lf_setlock): Ditto.
* select.cc (pselect): Ditto.  Set per-thread signal_arrived using
set_thread_waiting().
* gendef: Don't special case handling of _cygtls::sig for threads.
* gentls_offsets: Use #pragma once in tlsoffsets.h.
* ntdll.h: Use #pragma once.
* poll.cc: Reflect set_signal_mask() argument reordering.
* posix_ipc.cc (ipc_mutex_lock): Use cancelable_wait rather than WFMO.
(ipc_cond_timedwait): Set perl-thread signal arrived using
set_thread_waiting().
* security.h: Use #pragma once.
* signal.cc (abort): Reflect set_signal_mask() argument reordering.
(clock_nanosleep): Ditto.  Change call to cancelable_wait to properly specify
handling of cancel and interrupt.
(sigwaitinfo): Remove handling of per-thread event in favor of per-thread
signal_arrived.  Use cancelable_wait rather than WFSO.
* sigproc.cc (signal_arrived): Delete definition.
(create_signal_arrived): Ditto.
* sigproc.h (signal_arrived): Delete declaration.
(set_signal_mask): Avoid defining as a "C" function.  Don't conditionally
declare.
(create_signal_arrived): Delete declaration.
* syscalls.cc (rename): Use cygwait() rather than WFSO.
* thread.h (fast_mutex::lock): Use cw_infinite rather than LARGE_NULL.
* wait.cc (wait4): Ditto.
* thread.cc (pthread_mutex::lock): Ditto.
(pthread::join): Ditto.
(semaphore::_wait): Ditto.
(pthread_kill): Remove set_threadkill() accommodation.
* tlsoffsets.h: Regenerate.
2012-07-21 22:58:20 +00:00