Commit Graph

6033 Commits

Author SHA1 Message Date
Corinna Vinschen 6bc64eac26 * autoload.cc (GetModuleHandleExW): Define.
* dlfcn.cc: Throughout mark exported symbols as extern "C".
	(dlopen): Unignore flags argument.  Define ret to NULL.  Fix typo in
	comment.  Support Glibc flags RTLD_NOLOAD and RTLD_NODELETE.
	* include/dlfcn.h:  Clean up comments.
	(RTLD_NODELETE): Define.
	(RTLD_NOLOAD): Define.
	(RTLD_DEEPBIND): Define.
2011-08-16 14:44:26 +00:00
Corinna Vinschen 56c387b1b3 * pipe.cc (pipe): Just call _pipe with O_BINARY mode. Move code to
generate normalized pathnames from here...
	(_pipe): ...to here.
2011-08-15 16:05:13 +00:00
Corinna Vinschen f8b8b1be3c * miscfuncs.cc (CreatePipeOverlapped): New function.
(ReadPipeOverlapped): Ditto.
	(WritePipeOverlapped): Ditto.
	* miscfuncs.h: Declare new functions.
	* pinfo.cc (commune_process): Call WritePipeOverlapped instead of
	WriteFile.  Set timeout to 1 sec.
	(_pinfo::commune_request): Call ReadPipeOverlapped instead of ReadFile.
	Set timeout to 0.5 secs.
	* sigproc.cc (sig_send): Create pipe using CreatePipeOverlapped.
2011-08-13 10:28:15 +00:00
Christopher Faylor e1d5167d20 * miscfuncs.cc (create_pipe): Delete obsolete function.
* miscfuncs.h (create_pipe): Delete define.
* pipe.c (fhandler_pipe::create_selectable): Delete obsolete comment.
2011-08-12 16:55:35 +00:00
Corinna Vinschen ad39174691 * fhandler_proc.cc (fhandler_proc::closedir): Don't free, but delete
instead.

	Also fix previous ChangeLog entry.
2011-08-12 12:35:37 +00:00
Corinna Vinschen 1f08558f14 * fhandler.h (fhandler_proc::opendir): Declare.
(fhandler_proc::closedir): Declare.
	* fhandler_proc.cc (fhandler_proc::opendir): New method.  Fetch list
	of active processes here once to avoid potential duplicates.
	(fhandler_proc::closedir): New method.
2011-08-12 12:31:08 +00:00
Corinna Vinschen 6e2c582323 * fhandler_proc.cc (fhandler_proc::get_proc_fhandler): Don't allow to
access process info by using the Windows PID.
	* fhandler_process.cc (fhandler_process::fstat): Ditto.
	(fhandler_process::fill_filebuf): Ditto.
2011-08-11 16:43:26 +00:00
Corinna Vinschen 3b7cd74bfd * (winpids::add): Make sure to store always a Windows PID in
pidlist, even if pid is a Cygwin PID.
	(winpids::enum_processes): Fetch Cygwin processes from listing of
	shared cygwin object dir in the native NT namespace.  Only if winpid
	is true, fetch Windows processes using an additional call to
	NtQuerySystemInformation.
2011-08-11 07:28:42 +00:00
Corinna Vinschen d10f0e106e * fhandler_process.cc (format_process_status): Always print process name
even for zombies.
	(get_mem_values): Fix loop fetching working set list to avoid out of
	memory conditions.  Return all mem values set to 0 for zombies.
	* ntdll.h (STATUS_PROCESS_IS_TERMINATING): Define.
2011-08-10 13:13:09 +00:00
Corinna Vinschen afe817741c * heap.cc (eval_initial_heap_size): New function fetching the heap
size from the LoaderFlags field in the PE/COFF header.
	(heap_init): Call eval_initial_heap_size rather than
	cygwin_shared->heap_chunk_size to fetch the initial heap size.
	* shared.cc (shared_info::heap_chunk_size): Remove.
	* shared_info.h (class shared_info): Drop heap_chunk member.
	(CURR_SHARED_MAGIC): Update.
2011-08-09 12:00:27 +00:00
Corinna Vinschen c29da54058 * ntdll.h (STATUS_NOT_FOUND): Define.
* ntea.cc (read_ea): Return correct ENOTSUP rather than EOPNOTSUPP.
	Handle STATUS_INVALID_DEVICE_REQUEST and STATUS_NOT_FOUND.  Explain
	why.  Convert conditional to switch statement.
	(write_ea): Return correct ENOTSUP rather than EOPNOTSUPP.  Handle
	STATUS_INVALID_DEVICE_REQUEST.  Convert conditional to switch statement.
2011-08-09 09:14:28 +00:00
Corinna Vinschen f0b7368c68 * resource.cc (getrlimit): Just return RLIM_INFINITY in a request for
RLIMIT_AS.
2011-08-07 19:49:08 +00:00
Corinna Vinschen 60b55c4c18 * fhandler_process.cc (format_process_maps): Actually print info about
the application heap of the printed process, not of the current process.
2011-08-07 11:04:32 +00:00
Corinna Vinschen a5408d982c * net.cc (socketpair): Release sb0 if there's no space left for sb1. 2011-08-04 08:22:11 +00:00
Yaakov Selkowitz bfc071dbce * cygwin.din (clock_nanosleep): Export.
* posix.sgml (std-notimpl): Move clock_nanosleep from here...
(std-susv4): ... to here.
(std-notes): Note limitations of clock_nanosleep.
* signal.cc (clock_nanosleep): Renamed from nanosleep, adding clock_id
and flags arguments and changing return values throughout.
Improve checks for illegal rqtp values.  Add support for
CLOCK_MONOTONIC and TIMER_ABSTIME.
(nanosleep): Rewrite in terms of clock_nanosleep.
(sleep): Ditto.
(usleep): Ditto.
* thread.cc: Mark clock_nanosleep in list of cancellation points.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-08-03 19:17:02 +00:00
Christopher Faylor 2964913236 * dll_init.cc: Use fabort in favor of api_fatal and fork_info->abort where
appropriate throughout.
(fabort): Define.
(dll_list::topsort): Don't print sorting information.  Fix formatting.
(dll_list::topsort_visit): Fix formatting.
(dll_list::load_after_fork_impl): Perform comment fixups.
* sigproc.cc (child_info_fork::abort): (for now?) Always print cause of fork
failure.
* include/sys/strace.h (strace_vprintf): Remove _STRACE_NOTALL when printing.
We really do want to see this.
2011-08-03 17:58:59 +00:00
Yaakov Selkowitz f0968c1e7e * cygtls.h (struct _local_storage): Add cw_timer member.
* cygtls.cc (_cygtls::init_thread): Initialize locals.cw_timer.
(_cygtls::fixup_after_fork): Ditto.
* tlsoffsets.h: Regenerate.
* ntdll.h (enum _TIMER_INFORMATION_CLASS): Define.
(struct _TIMER_BASIC_INFORMATION): Define.
(NtQueryTimer): Declare function.
* thread.h (cancelable_wait): Change timeout argument to
PLARGE_INTEGER and provide NULL default.
(fast_mutex::lock): Adjust accordingly.
(pthread_cond::wait): Change timeout argument to PLARGE_INTEGER
and default to NULL.
* thread.cc (cancelable_wait): Change timeout argument to
PLARGE_INTEGER.  Initialize _cygtls.locals.cw_timer if needed.
Use NT waitable timers for handling timeout.  Return remaining time
to timeout argument if timeout was relative.
(pthread_cond::wait): Change timeout argument to PLARGE_INTEGER.
Adjust to change in cancelable_wait.
(pthread_mutex::lock): Adjust to change in cancelable_wait.
(pthread_spinlock::lock): Ditto.
(pthread::join): Ditto.
(__pthread_cond_dowait): Change waitlength argument to PLARGE_INTEGER.
Adjust to changes in cancelable_wait and pthread_cond::wait.
(pthread_cond_timedwait): Adjust to change in __pthread_cond_dowait.
(pthread_cond_wait): Ditto.
(semaphore::_timedwait): Adjust to change in cancelable_wait.
(semaphore::_wait): Ditto.
* exceptions.cc (handle_sigsuspend): Ditto.
* signal.cc (nanosleep): Ditto.
* wait.cc (wait4): Ditto. Fix copyright dates.
* times.cc (FACTOR, NSPERSEC): Move from here...
* hires.h (FACTOR, NSPERSEC): ...to here.
2011-08-03 16:40:48 +00:00
Corinna Vinschen d32e0bfc08 * syscalls.cc (faccessat): Fix parens in flag expression when calling
build_fh_name.

	* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Fix typo in
	comment.
	* fhandler_socket.cc (fhandler_socket::bind): Ditto.
	* path.cc (symlink_worker): Ditto.
2011-08-01 17:01:38 +00:00
Christopher Faylor ab0887572f * dll_init.cc (dll_list::load_after_fork_impl): Add a hint to an error message. 2011-08-01 13:11:37 +00:00
Christopher Faylor dc3dc49831 * sigproc.cc (pending_signals::pending): Define new function.
(sig_dispatch_pending): Avoid calling sig_send if there are no pending signals.
2011-08-01 00:02:04 +00:00
Corinna Vinschen c114604529 * fhandler.h (class fhandler_dev_mem): Remove dup method declaration.
* fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Accommodate the
	fact that the entire fhandler gets copied over to the child in
	operator =.
	* fhandler_floppy.cc (fhandler_dev_floppy::dup): Ditto.
	* fhandler_raw.cc (fhandler_dev_raw::dup): Ditto.
	* fhandler_serial.cc (fhandler_serial::dup): Ditto.
	* fhandler_socket.cc (fhandler_socket::dup): Ditto.
	* fhandler_virtual.cc (fhandler_virtual::dup): Ditto.
	* fhandler_mem.cc (fhandler_dev_mem::dup): Ditto.  Remove entirely.
2011-07-31 12:37:52 +00:00
Christopher Faylor 6c6fe41781 add missing entry 2011-07-30 21:09:20 +00:00
Christopher Faylor 53ad6f1394 * cygthread.cc (cygthread::async_create): Define new function.
* cygthread.h (cygthread::create): Use correct regparm.
(cygthread::standalone): Delete from class and from all constructors.
(cygthread::cygthread): Use three only arguments for detached threads, and
start the thread via QueueUserAPC/async_create.
* dcrt0.cc (dll_crt0_0): Remove handling for wincap.has_buggy_thread_startup.
(dll_crt0_1): Ditto.
* wincap.cc: Ditto throughout.
* wincap.h: Ditto.
2011-07-30 20:50:23 +00:00
Christopher Faylor f7e198a665 * fhandler.h (fhandler_base_overlapped::size): Declare/define size() function
for consistency.
(fhandler_termios::size): Ditto.
(fhandler_pty_common::size): Ditto.
2011-07-30 20:01:27 +00:00
Corinna Vinschen 9e242ba461 * fhandler_registry.cc (fhandler_registry::dup): Duplicate value_name. 2011-07-30 08:09:44 +00:00
Corinna Vinschen c487f2fef5 Throughout change "WinSock" to "Winsock" in comments.
* fhandler_socket.cc (fhandler_socket::sendmsg): Add missing call to
	get_inet_addr to convert AF_LOCAL to AF_INET sockets.
	* net.cc (cygwin_socket): Workaround UDP Winsock problem.  Add comment
	to explain why.
	* select.cc: Include winsock2.h rather than winsock.h.
2011-07-29 12:47:54 +00:00
Corinna Vinschen 303dc0230d * fhandler_disk_file.cc (__DIR_mounts::eval_ino): Create path_conv
with PC_KEEP_HANDLE flag.
	* path.h (path_conv::operator =): Duplicate UNICODE path as well.
	* security.cc (check_file_access): Use path_conv handle if available.
	* syscalls.cc (access): Create fhandler with PC_KEEP_HANDLE flag set.
	(euidaccess): Ditto.
	(faccessat): Ditto.
2011-07-26 13:30:41 +00:00
Corinna Vinschen f4529884e5 * ntdll.h: Fix typo in comment.
* path.cc: Ditto.
2011-07-26 09:54:11 +00:00
Corinna Vinschen f4fc0c59e3 * fhandler_console.cc (fhandler_console::ioctl): Fetch console events
using PeekConsoleInput and return only key down events in buf.
	* fhandler_tty.cc (fhandler_pty_slave::ioctl): Always return EINVAL
	if PeekNamedPipe fails.
	(fhandler_pty_master::ioctl): Ditto.
2011-07-25 15:19:35 +00:00
Corinna Vinschen cfb517f39a * fhandler_tty.cc (fhandler_pty_slave::ioctl): Drop FIONBIO case.
Handle FIONREAD.
	(fhandler_pty_master::ioctl): Ditto.  Call fhandler_base::ioctl to
	decode default condition.
	* fhandler_console.cc (fhandler_console::ioctl): Handle FIONREAD.
2011-07-22 18:50:42 +00:00
Christopher Faylor e9b5cc32f7 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc: Add #include for asm/socket.h for dealing with FIONREAD.
(fhandler_base::ioctl): Special-case errno for FIONREAD.
* fhandler_dsp.cc (fhandler_dev_dsp::ioctl): Rename parameter for consistency.
Call fhandler_base::ioctl to decode default condition.
* fhandler_serial.cc (fhandler_serial::ioctl): Ditto.
* fhandler_tty.cc (fhandler_pty_slave::ioctl): Call fhandler_base::ioctl to
decode default condition.
* fhandler_windows.cc (fhandler_windows::ioctl): Ditto.
2011-07-21 20:21:46 +00:00
Corinna Vinschen 37aeec7f72 * heap.cc (eval_start_address): Simplify test for large address
awareness of executable, which works for 32 and 64 bit systems.
	Change comment accordingly.
2011-07-21 17:52:05 +00:00
Corinna Vinschen 86719a10d0 * heap.cc (eval_start_address): New static function to evaluate the
best start address for the application heap.
	(heap_init): Call eval_start_address to fetch the start value for
	start_address.  Move preceeding comment to eval_start_address.
2011-07-21 15:23:24 +00:00
Yaakov Selkowitz 8a7b0a00df * cygwin.din (pthread_condattr_getclock): Export.
(pthread_condattr_setclock): Export.
* posix.sgml (std-notimpl): Move pthread_condattr_getclock and
pthread_condattr_setclock from here...
(std-susv4): ... to here.
* sysconf.cc (sca): Set _SC_CLOCK_SELECTION to _POSIX_CLOCK_SELECTION.
* thread.cc: (pthread_condattr::pthread_condattr): Initialize clock_id.
(pthread_cond::pthread_cond): Initialize clock_id.
(pthread_cond_timedwait): Use clock_gettime() instead of gettimeofday()
in order to support all allowed clocks.
(pthread_condattr_getclock): New function.
(pthread_condattr_setclock): New function.
* thread.h (class pthread_condattr): Add clock_id member.
(class pthread_cond): Ditto.
* include/pthread.h: Remove obsolete comment.
(pthread_condattr_getclock): Declare.
(pthread_condattr_setclock): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-07-21 09:39:22 +00:00
Yaakov Selkowitz 7ec669539f * sysconf.cc (sca): Return -1 for _SC_THREAD_ROBUST_PRIO_INHERIT,
_SC_THREAD_ROBUST_PRIO_PROTECT, and _SC_XOPEN_UUCP.
(SC_MAX): Redefine accordingly.
(csa): Return strings for _CS_POSIX_V7_THREADS_CFLAGS,
_CS_POSIX_V7_THREADS_LDFLAGS, and _CS_V7_ENV.
(CS_MAX): Redefine accordingly.
* include/limits.h (LONG_BIT): Define.
(WORD_BIT): Define.
2011-07-18 23:08:09 +00:00
Corinna Vinschen b6c42976eb * heap.cc (heap_init): Change type of largest_found to PVOID. Start
querying memory at 0x20000000.  Use largest_found pointer when trying
	to allocate largest free memory area found.
2011-07-18 08:43:49 +00:00
Corinna Vinschen 8924483160 * fhandler_console.cc (fhandler_console::input_tcsetattr): Revert to
setting ENABLE_PROCESSED_INPUT depending on ISIG and IGNBRK.
	(fhandler_console::tcgetattr): Set ISIG depending on
	ENABLE_PROCESSED_INPUT as well.
2011-07-14 10:02:11 +00:00
Corinna Vinschen f55fc99c77 * fhandler_serial.cc (fhandler_serial::raw_read): Handle non-blocking
case more thoroughly.
2011-07-13 18:59:41 +00:00
Christopher Faylor b4efd5410c * setup_handler (setup_handler): Change break to goto out, missed in 2011-07-06
changes.
2011-07-13 17:53:21 +00:00
Christopher Faylor c57fc872f5 * fhandler_tty.cc (fhandler_pty_slave::ioctl): Remove erroneous support for
TIOCLINUX for pty.  Get rid of unneeded EINVAL handling in wake of tty removal.
Remove now-unneeded variable.
2011-07-11 00:03:55 +00:00
Corinna Vinschen 071bf81128 * include/netdb.h (gethostbyname2): Declare. 2011-07-10 13:22:48 +00:00
Eric Blake 14295a59d3 pthread_sigmask: fix return value to match POSIX
* signal.cc (handle_sigprocmask): Return error rather than setting
errno, for pthread_sigmask.
(sigprocmask): Adjust caller.
2011-07-10 00:01:33 +00:00
Corinna Vinschen 66965620fc * miscfuncs.cc (yield): Drop thread priority only once. 2011-07-07 06:21:24 +00:00
Christopher Faylor 57e64035f8 * exceptions.cc (_cygtls::interrupt_now): Back out previous change since it
could theoretically cause a non-CTRL-C-able program if a program has suffered
memory corruption.
(setup_handler): Ditto.
2011-07-06 18:44:06 +00:00
Corinna Vinschen 5e6a91549e * sched.c (sched_yield): Just call SwitchToThread because yield now
potentially switches CPU.
2011-07-06 18:35:44 +00:00
Christopher Faylor 51b5e9211d * exceptions.cc (_cygtls::interrupt_now): Don't check for spinning here.
(setup_handler): Check for spinning here, assuming that it is transitory and
should not affect the retry loop.
2011-07-06 18:14:22 +00:00
Christopher Faylor d1204b6378 * exceptions.cc (CALL_HANDLER_RETRY_INNER): Rename to reflect different
functionality.
(CALL_HANDLER_RETRY_OUTER): New define.
(setup_handler): Add outer loop to signal handler to try harder to deliver the
signal.
* miscfuncs.cc (yield): Drop priority and use SleepEx() to force thread
rescheduling rather than relying on SwitchToThread().
2011-07-06 16:33:30 +00:00
Corinna Vinschen fa0b926af9 * sigproc.cc (wait_sig): Fix debug output. 2011-07-06 12:39:36 +00:00
Corinna Vinschen 7616b79e0d * fhandler_console.cc (fhandler_console::input_tcsetattr): Make
ENABLE_PROCESSED_INPUT flag only depending on value of IGNBRK.
	(fhandler_console::tcgetattr): Don't set ISIG depending on
	ENABLE_PROCESSED_INPUT, set IGNBRK instead.
2011-07-05 18:01:13 +00:00
Corinna Vinschen 3fe31f2633 * security.cc (get_file_sd): Fix comment. 2011-07-05 15:42:43 +00:00
Corinna Vinschen 8c1f7cf707 * fhandler.cc (fhandler_base::open): Never create files with WRITE_DAC
access.  Explain why.
	* fhandler_disk_file.cc (fhandler_base::fstat_helper): Improve debug
	output.
2011-07-05 12:02:10 +00:00
Corinna Vinschen fcacca02dd * fhandler.cc (fhandler_base::open): Don't open file with WRITE_DAC
access on remote filesystem.  Explain why.
	* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto for
	directories.
	* fhandler_socket.cc (fhandler_socket::bind): Ditto for sockets.
	* path.cc (symlink_worker): Ditto for symlinks.
2011-07-05 09:59:34 +00:00
Christopher Faylor 3dce4ce653 * environ.cc (tty_is_gone): Wrap warning at 80 characters. 2011-07-04 18:14:31 +00:00
Corinna Vinschen fc3e7da6b0 Throughout, open console handles with sharing for reading and writing.
* dcrt0.cc (insert_file): Open file with full sharing allowed.
	* hookapi.cc (find_first_notloaded_dll): Ditto.
	* spawn.cc (av::fixup): Ditto.
2011-07-04 15:25:36 +00:00
Corinna Vinschen d3ed549d51 * dtable.cc (dtable::init_std_file_from_handle): Change test for console
device in call to fh->init to avoid conhost crash on W7.
2011-07-04 09:47:10 +00:00
Corinna Vinschen d51a9c25bd * environ.cc (environ_init): Reinstantiate on-the-fly CYGWIN variable
test and call to parse_options if found.
2011-07-04 09:39:20 +00:00
Christopher Faylor b9a0725042 * fhandler.cc (fhandler_base::open_with_arch): Call close_on_exec last to avoid
setting close_on_exec for archetype.
* fhandler_tty.cc (fhandler_pty_master::setup): Protect {from,to}_pty handles.
Use consistent naming in debug output.  Use inheritable handles and...
(fhandler_pty_master::fixup_after_fork): ...avoid duplicating handles here.
(fhandler_pty_slave::open): Don't set close_on_exec flag here.
2011-07-04 05:08:28 +00:00
Christopher Faylor c38da4ee1d * dtable.cc (cnew): Fix whitespace. 2011-07-01 22:04:20 +00:00
Corinna Vinschen 00994759b6 * include/sys/param.h (NGROUPS): Redefine as NGROUPS_MAX.
(MAXHOSTNAMELEN): Redefine with same value as MAX_HOSTNAME_LEN.  Change
	comment.
	(MAXPATHLEN): Improve comment.
	(MAXSYMLINKS): Define and add comment.
2011-07-01 12:45:25 +00:00
Corinna Vinschen 9780b0da3c * fhandler.cc (fhandler_base::open): Move NFS-specific code into the
code block handling FH_FS stuff.
2011-07-01 11:23:43 +00:00
Corinna Vinschen 3d938be6c5 * dtable.cc (fh_oom): Remove.
(fh_calloc): Remove.
	(cnew): Redefine to handle NULL returns from cmalloc.
	(build_fh_name): Accommodate new definition of cnew.  Remove unneeded
	test for fh_oom.
	(fh_alloc): Ditto.
2011-06-30 14:04:51 +00:00
Corinna Vinschen 4b626add7e * fhandler_console.cc (fhandler_console::read): Add comment.
(fhandler_console::input_tcsetattr): Don't set ENABLE_PROCESSED_INPUT
	if IGNBRK flag is set.
2011-06-30 13:55:57 +00:00
Corinna Vinschen 9e1fd6bcf7 * dtable.cc (fh_oom): New static fhandler storage.
(fh_calloc): New static function.  Add a comment to explain why this
	is needed.
	(cnew): Call fh_calloc as placement argument.
	(build_fh_name): Check return code from cnew against address of
	fh_oom to test for out of memory condition.
	(fh_alloc): Ditto.
	(build_fh_pc): Avoid a crash due to useing a NULL fhandler.
	* pipe.cc (fhandler_pipe::create): Check if build_fh_dev returned a
	valid pointer before using it.
2011-06-30 09:37:36 +00:00
Corinna Vinschen cb26eb6868 * fhandler_process.cc (heap_info::fill_if_match): Rename info to
note that this heap is a Windows heap.
	(format_process_maps): Print info about application heap.
2011-06-28 10:21:34 +00:00
Corinna Vinschen b9a5b2c45f * fhandler_console.cc (fhandler_console::read): Don't generate ^@ on
Ctrl+Alt+Space.
2011-06-24 08:25:19 +00:00
Corinna Vinschen c80de4f912 * fhandler_tty.cc (fhandler_pty_master::setup): Create pty pipes
non-inheritable.
2011-06-22 07:58:01 +00:00
Corinna Vinschen 49e6e30f7a * fhandler_tty.cc (fhandler_pty_master::setup): Fix crash in debug
output.
2011-06-22 07:37:49 +00:00
Corinna Vinschen 787908c173 * path.cc (normalize_win32_path): Skip all slashes after recognizing
a ".." path component.  Add comment.
2011-06-18 08:36:59 +00:00
Corinna Vinschen c36cd56c54 * fhandler.cc (fhandler_base::open): Drop local create_options variable.
Use options member instead.
	* fhandler.h (class fhandler_base): Change type of access member to
	ACCESS_MASK.  Change get_access and set_access methods accordingly.
	Add options member.  Add get_options and set_options methods.
	(class fhandler_disk_file): Add prw_handle.
	(fhandler_disk_file::prw_open): Declare.
	(fhandler_disk_file::close): Declare.
	(fhandler_disk_file::dup): Declare.
	(fhandler_disk_file::fixup_after_fork): Declare.
	* fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file):
	Initialize prw_handle to NULL.
	(fhandler_disk_file::close): Close prw_handle.
	(fhandler_disk_file::dup): New method.
	(fhandler_disk_file::fixup_after_fork): Set prw_handle to NULL since
	prw_handle is not inherited.
	(fhandler_disk_file::prw_open): New method.  Add long comment to
	explain current behaviour.
	(fhandler_disk_file::pread): Revert previous change.  Change to use
	prw_handle if possible.
	(fhandler_disk_file::pwrite): Change to use prw_handle if possible.
2011-06-17 11:04:44 +00:00
Corinna Vinschen a716252619 * dcrt0.cc (dll_crt0_1): Call strace.dll_info after call to pinfo_init.
* strace.cc (strace::hello): Drop printing DLL information here since
	application info is not always available at this point.
	(strace::dll_info): New method to print DLL info.
	* include/sys/strace.h (strace::dll_info): Declare.
2011-06-17 08:30:27 +00:00
Corinna Vinschen 2ae8e0e482 * dtable.cc (handle_to_fn): Accommodate name change of pty named pipes,
otherwise ptys are not recognized.
2011-06-17 08:27:32 +00:00
Christopher Faylor 6f294f8601 * fhandler_console.cc (fhandler_console::set_unit): Set pc.file_attributes() to
reflect existence.
* fhandler.h (fhandler_pty_common::fhandler_pty_common): Ditto.
* pinfo.cc (_pinfo::set_ctty): Output device numbers in hex.
2011-06-16 23:00:00 +00:00
Christopher Faylor 4d046729d1 * errno.cc (EIO): Lowercase "o" representative string. 2011-06-15 17:36:10 +00:00
Christopher Faylor c75b5b2d13 * cygheap.h (init_cygheap::ctty_on_hold): Remove conditionalized variable.
* dcrt0.cc (do_exit): Remove code which handled CYGWIN=tty style ttys.
* devices.in: Remove "/dev/ttym".
* dtable.cc: Rename tty to pty where appropriate throughout.
(dtable::stdio_init): Use new t->is_console rather than using now-deleted hwnd
element in tty structure.
(dtable::init_std_file_from_handle): Remove code which handled CYGWIN=tty style
ttys.
(fh_alloc): Ditto.
* fhandler.h: Rename tty to pty where appropriate.
(fhandler_pty_common): Delete output_done_event, ioctl_request_event,
ioctl_done_event.
(fhandler_pty_master::setup): Delete argument.
(fhandler_tty_master): Delete.
(fhandler_union): Delete __tty_master.
* fhandler_console.cc (use_tty): Delete.
(fhandler_console::get_tty_stuff): Set is_console to true rather than calling
sethwnd.
(fhandler_console::send_winch_maybe): Remove CYGWIN=tty considerations.
(fhandler_console::input_tcsetattr): Ditto.
* fhandler_termios.cc (fhandler_termios::tcsetpgrp): Use new t->is_console
rather than using now-deleted hwnd element in tty structure.
* fhandler_tty.cc: Rename tty to pty where appropriate throughout.
(tty_master): Delete.
(process_input): Ditto.
(process_output): Ditto.
(process_ioctl): Ditto.
(fhandler_tty_master::*): Ditto.
(fhandler_pty_master::process_slave_output): Remove CYGWIN=tty considerations.
(fhandler_pty_slave::open): Ditto for *_done_event.
(fhandler_pty_slave::write): Ditto.
(fhandler_pty_slave::ioctl): Ditto.
(fhandler_pty_slave::fch_open_handles): Ditto.
(fhandler_pty_slave::fch_set_sd): Ditto.
(fhandler_pty_slave::fch_close_handles): Ditto.
(fhandler_pty_common::close): Ditto.
(fhandler_pty_master::setup): Ditto.  Remove now-unneeded ispty parameter.
(fhandler_pty_master::open): Reflect argument removal for tty::allocate.
* select.cc: Rename tty to pty where appropriate throughout.
* sigproc.cc (proc_subproc): Remove CYGWIN=tty considerations.
* tty.cc (ttyslot): Accommodate CYGWIN=tty removal.
(tty_list::init_session): Ditto.
(tty_list::attach): Ditto.
(tty::create_master): Delete.
(tty_list::terminate): Ditto.
(tty_list::allocate): Delete "with_console" parameter.  Remove CYGWIN=tty
considerations.
(tty::init): Set is_console = false.  Use 'false' for was_opened since it is a
boolean.
* tty.h (*_{DONE,REQUEST}_EVENT): Delete.
(tty_min::is_console): Declare new field which replaces hwnd.
(tty_min::gethwnd): Delete.
(tty_min::sethwnd): Ditto.
(tty_list::allocate): Delete parameter.
(tty_list::terminate): Delete declaration.
* include/sys/cygwin.h (PID_USETTY): Redefine to PID_UNUSED1 and change comment
to reflect its availability.
2011-06-14 21:48:43 +00:00
Christopher Faylor 0fdbb2d0cd * fhandler_tty_slave.cc (fhandler_tty_slave::fhandler_tty_slave): Revert
previous change since unit 0 is perfectly valid.
2011-06-13 23:49:00 +00:00
Christopher Faylor c3a9063f83 Rename FH_BAD to FH_NADA throughout.
* devices.h (FH_ERROR): New value.
(iscons_dev): Extend to detect all the console device types.
* devices.in: Set aside storage for FH_ERROR.
* dtable.cc (dtable::init_std_file_from_handle): Use iscons_dev to detect when
device is a console.
(fh_alloc): Pass device to console constructor.
(build_fh_pc): Short circuit when we detect that the constructor saw an error.
* fhandler.h (fhandler_console::fhandler_console): Accept fh_devices parameter.
(get_tty_stuff): Change to void.
* fhandler_console (fhandler_console::set_unit): Set device to FH_ERROR on
attempt to access anything other than the current console.
(fhandler_console::get_tty_stuff): Change to void return.
(fhandler_console::open): Return EPERM on FH_ERROR device type.
(fhandler_console::fhandler_console): Set the device type appropriately before
calling get_tty_stuff and rely on that function to reset it if necessary.
2011-06-12 20:15:26 +00:00
Christopher Faylor 1516a0b4d7 * environ.cc (create_upcaseenv): Delete.
(ucenv): Don't honor create_upcaseenv.
(environ_init): Remove early retrieval of CYGWIN environment variable.  Change
comment to reflect new behavior.
2011-06-10 15:06:13 +00:00
Christopher Faylor b6510ccdcd * child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
(child_info::old_title): Delete.
(child_info::~child_info_spawn): Remove recording of old_title.
* dcrt0.cc (title_buf): Delete.
(child_info_spawn::handle_spawn): Remove recording of old_title.
(dll_crt0_1): Get rid of all title handling.
(do_exit): Ditto.
* environ.cc (known): Delete strip_title and title.
* fhandler_console.cc (fhandler_console::write): Remove recording of old_title.
* globals.cc (exit_states): Remove ES_TITLE.
(display_title): Delete.
(strip_title_path): Delete.
(old_title): Delete.
* spawn.cc (spawn_guts): Remove old_title accommodation.
2011-06-09 21:20:27 +00:00
Christopher Faylor e254790b66 * environ.cc (envcache): Delete.
(known): Remove envcache.
(getwinenv): Don't honor envcache setting.
2011-06-09 19:08:22 +00:00
Christopher Faylor b9cf88ddba * environ.c: Move code earlier to allow:
(_addenv): Call parse_options() when CYGWIN environment variable is being
changed.
(parse_options): Change parameter to 'const'.
2011-06-09 17:50:41 +00:00
Christopher Faylor bb37277ac2 * environ.cc (tty_is_gone): Add missing space to message. 2011-06-08 19:51:15 +00:00
Christopher Faylor 022e15dc60 * environ.cc (settings::set_process_state): Delete.
(tty_is_gone): New function.
(known): Change "tty" to call tty_is_gone().  Remove unneeded '&' from
beginning of function address.
(parse_options): Remove set_process_state handling.
* shared_info.h (CURR_USER_MAGIC): Reset.
(user_info::warned_notty): New member.
2011-06-08 19:27:48 +00:00
Christopher Faylor 0791c40b20 * fhandler_console.cc (fhandler_console::open_shared_console): Semi-revert to
using fixed location for console stuff.
* shared.cc (offsets): Ditto.  Comment.
* shared_info (shared_locations): Re-add SH_SHARED_CONSOLE.
2011-06-07 20:55:10 +00:00
Christopher Faylor b86f999af1 whitespace elimination 2011-06-06 05:02:13 +00:00
Christopher Faylor daf7238603 * fhandler_disk_file.cc (fhandler_disk_file::pread): Reset windows file
position pointer back to previous location after successful read.
2011-06-06 00:25:44 +00:00
Christopher Faylor d5cb221b85 * fhandler_console.cc (fhandler_console::open_shared_console): Don't zero
handle to open_shared since it is supposed to be an input.
(enum_windows): Set handle input to open_shared to NULL since it does not
represent any previously opened shared region.
* shared.cc (open_shared): Tweak debugging output.
2011-06-05 02:10:31 +00:00
Christopher Faylor 665f9a59a4 * ntdll.h (FILE_PIPE_*): Define constants.
* select.cc (pipe_data_available): Detect closing state.
2011-06-04 01:06:17 +00:00
Christopher Faylor cb353ff36f * pinfo.cc (_pinfo::set_ctty): Don't reset myself->{pgid,sid} if terminal has
no pgid or sid settings.
2011-06-04 00:29:19 +00:00
Christopher Faylor 32bf308231 * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Only raise SIGPIPE
when writing.
* fhandler.h: Include "tty.h".
(fhandler_termios::_tc): Rename from tc.
(fhandler_termios::tc): New method.
(fhandler_termios::tcinit): Remove an argument.
(fhandler_termios::get_ttyp): Use method to retrieve value.
(fhandler_console::console_state): Move here.
(fhandler_console::dev_state): Delete.
(fhandler_console::shared_console_info): Define.
(fhandler_console::open_shared_console): Move this function under
fhandler_console umbrella.
(fhandler_console::tc): Define.  Return static value.
(fhandler_console::focus_aware): Accommodate deletion of dev_state.
(fhandler_console): Add tty_list::get_cttyp as a friend.
* fhandler_console.cc (dev_state): Redefine as a pointer within
shared_console_info and change dev-> to dev.  throughout.
(fhandler_console::shared_console_info): Move into fhandler_console.
(fhandler_console::open_shared_console): Move into fhandler_console change
argument to simple bool.
(enum_windows): Accommodate changes to console_state and open_shared_console.
(console_unit::console_unit): Ditto.
(fhandler_console::get_tty_stuff): Accommodate change to dev_state.
(tty_list::get_cttyp): Accommodate change to
handler_console::shared_console_info.
(fhandler_console::read): Accommodate change from tc to tc ().
(fhandler_console::set_input_state): Ditto.
(fhandler_console::open): Accommodate tcinit argument change and change from tc
to tc().
(fhandler_console::input_tcsetattr): Accomodate change from tc to tc().
(fhandler_console::input_tcsetattr): Ditto.
(fhandler_console::write_normal): Ditto.
(fhandler_console::init): Ditto.
(fhandler_console::igncr_enabled): Ditto.
* fhandler_termios.cc (fhandler_termios::tcinit): Remove first argument.
Expect tc() to have been set up first.  Use tc() rather than tc.
(fhandler_termios::tcsetpgrp): Accomodate change from tc to tc().
(fhandler_termios::tcgetpgrp): Ditto.
(fhandler_termios::bg_check): Ditto.
(fhandler_termios::line_edit: Ditto.
(fhandler_tty_master::set_winsize): Ditto.
(fhandler_tty_slave::open): Ditto.
(fhandler_tty_slave::init): Ditto.
(fhandler_pty_master::write): Ditto.
(fhandler_pty_master::setup): Ditto.  Accommodate change in arguments to
tcinit.
(fhandler_tty_slave::fch_open_handles): Set _tc directly.
(tty_min::is_orphaned_process_group): Don't assume that parent pid exists.
* pinfo.cc (_pinfo::set_ctty): Reset myself->{pgid,sid} here if we were started
by a non-Cygwin process but the tty exists.
* shared_info.h (console_state): Delete from here.
* tty.h: Make multiple inclusion safe.
2011-06-04 00:12:29 +00:00
Christopher Faylor 83e4d35a89 * exceptions.cc (ctrl_c_handler): Simplify test for no parent tty.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Return NULL if ctty is
not tty/console.  Improve test for slave tty/pty device.
2011-06-01 01:47:51 +00:00
Christopher Faylor be9b5aba26 * external.cc (fillout_pinfo): Don't truncate ctty if it's < 0.
* select.cc (pipe_data_available): Avoid printing debug info by default or
suffer very large strace files.
2011-06-01 01:20:28 +00:00
Christopher Faylor a7a1247770 * select.cc (pipe_data_available): New function - uses NtQueryInformationFile
to return information about pipes.
(peek_pipe): Rewrite to use pipe_data_available for both read and write tests.
2011-06-01 00:57:49 +00:00
Christopher Faylor 106e3acf59 * dtable.cc (dtable::select_write): Add missing argument to debug_printf.
* fhandler.cc (fhandler_base_overlapped::setup_overlapped): Explicitly set
io_pending to false.
(fhandler_base_overlapped::has_ongoing_io): Call GetOverlappedResult to force
completion of I/O.
(fhandler_base_overlapped::wait_overlapped): Rewrite to correctly deal with
nonblocking reads and to make more race proof.
(fhandler_base_overlapped::raw_write): Deal with new enum values.
(fhandler_base_overlapped::raw_read): Ditto.  Don't deal with ongoing I/O here
since it makes no sense in the read context.
* fhandler.h (enum wait_return): Add overlapped_unknown,
overlapped_nonblocking_no_data.
* pipe.cc (pipe): Add debugging output.
2011-05-31 00:26:37 +00:00
Christopher Faylor de3c57f06e * dll_init.cc (dll_list::append): Eliminate increment of unused tot variable.
* dll_init.h (dll_list::tot): Delete.
(dll_list::populate_all_deps): Delete undefined function.
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Move EPIPE handling
under error condition.
2011-05-30 17:16:24 +00:00
Christopher Faylor 6642f7daa3 * dll_init.cc (reserve_upto): Remove.
(release_upto): Ditto.
(dll_list::reserve_space): New function to reserve space needed by DLL_LOAD
dlls early in the fork process.
(dll_list::load_after_fork): Rewrite to use recursion to track reservations it
makes while trying to make dlls land where they belong.
(dll_list::load_after_fork_impl): New function used by load_after_fork.
(dll_list::alloc): Initialize image base field.
* dll_init.h (dll_list::prefered_base): New field.
(dll_list::reserve_space): Declare new function.
(dll_list::load_after_fork): Declare new function.
* fork.cc (frok::child): call dll_list::reserve_space early, so we can retry if
it fails.
2011-05-30 16:09:29 +00:00
Christopher Faylor 7123c8b1fd * fhandler_termios.cc (fhandler_termios::bg_check): Do not return EIO when a
process group has no leader as this is allowed and does not imply an orphaned
process group.  Add a test for orphaned process groups.
(tty_min::is_orphaned_process_group): Define new function.
* tty.h (tty_min::is_orphaned_process_group): Define new function.
2011-05-30 06:58:00 +00:00
Christopher Faylor 977ad5434c * dll_init.cc (dll_list::find_by_modname): New function to search the dll list
for a module name only (no path).
(dll_list::alloc): Initialize newly-added members of struct dll.
(dll_list::append): New function to factor out the append operation
(used by dll_list::topsort).
(dll_list::populate_deps): New function to identify dll dependencies.
(dll_list::topsort): New function to sort the dll list topologically by
dependencies.
(dll_list::topsort_visit): New helper function for the above.
* dll_init.h (dll::ndeps): New class member.
(dll::deps): Ditto.
(dll::modname): Ditto.
(dll_list::find_by_modname): New function related to topsort.
(dll_list::populate_all_deps): Ditto.
(dll_list::populate_deps): Ditto.
(dll_list::topsort): Ditto.
(dll_list::topsort_visit): Ditto.
(dll_list::append): Ditto.
(pefile): New struct allowing simple introspection of dll images.
* fork.cc (fork): Topologically sort the dll list before forking
* child_info.h (CURR_CHILD_INFO_MAGIC): Refresh.
(child_info::refresh_cygheap): New function.
* spawn.cc (spawn_guts): Call refresh_cygheap before creating a new process to
ensure that cygheap_max is up-to-date.
* fork.cc (frok::parent): Ditto.
2011-05-30 06:52:12 +00:00
Christopher Faylor 3a88e09e7f * cygheap.cc (cygheap_dummy): Rename from cygheap_at_start.
(cygheap): Accommodate name change to cygheap_dummy.
(cygheap_init): Ditto.
(cygheap_fixup_in_child): Simplify slightly.
* fork.cc (fork): Add an advisory comment.
2011-05-30 06:24:53 +00:00
Christopher Faylor 57b670586c * fhandler.cc (fhandler_overlapped::wait_overlapped): Make sure that I/O is
cancelled on signal.
2011-05-29 15:30:27 +00:00
Christopher Faylor 6cd2e18523 * dll_init.cc (dll_list::alloc): Initialize dll::image_size.
(reserve_at): Don't reserve space needed by the target dll if the latter
overlaps the free region to be blocked.
(dll_list::load_after_fork): Use new version of reserve_at.
* dll_init.h (dll::image_size): New member.
(pefile): New struct.
2011-05-28 20:55:34 +00:00
Christopher Faylor 07f89f85db Revert previous checkins as they introduced a bug when running zsh. 2011-05-28 20:41:51 +00:00
Christopher Faylor 17a5c8c36e * dll_init.cc (reserve_upto): Remove.
(release_upto): Ditto.
(dll_list::reserve_space): New function to reserve space needed by DLL_LOAD
dlls early in the fork process.
(dll_list::load_after_fork): Rewrite to use recursion for tracking reservations
made while trying to make dlls land where they belong.
(dll_list::load_after_fork_impl): Ditto.
(dll_list::alloc): Initialize image base field.
* dll_init.h (struct dll_list): declare new functions.
(dll::image_size): New member.
2011-05-28 20:27:56 +00:00
Christopher Faylor a92339ab63 * dll_init.cc (dll_list::find_by_modname): New function to search the dll list
for a module name only (no path).
(dll_list::alloc): Initialize newly-added members of struct dll.
(dll_list::append): New function to factor out the append operation
(used by dll_list::topsort).
(dll_list::populate_deps): New function to identify dll dependencies.
(dll_list::topsort): New function to sort the dll list topologically by
dependencies.
(dll_list::topsort_visit): New helper function for the above.
* dll_init.h (dll::ndeps): New class member.
(dll::deps): Ditto.
(dll::modname): Ditto.
(dll_list::find_by_modname): New function related to topsort.
(dll_list::populate_all_deps): Ditto.
(dll_list::populate_deps): Ditto.
(dll_list::topsort): Ditto.
(dll_list::topsort_visit): Ditto.
(dll_list::append): Ditto.
(pefile): New struct allowing simple introspection of dll images.
* fork.cc (fork): Topologically sort the dll list before forking.
2011-05-28 20:17:09 +00:00
Christopher Faylor 8551087823 * dll_init.c (dll_list::load_after_fork): Don't clear in_forkee here.
* fork.cc (frok::errmsg): Rename from 'error'.
(frok::error): New function.  Handle conditional printing of error messages.
(frok::parent): Record hchild handle for use by error function.  Use
throughout.  Use error function rather than setting error pointer directly.
(fork): Clear is_forkee here.  Accommodate rename of 'error' to 'errmsg'.
* sigproc.cc (child_info::proc_retry): Detect EXITCODE_FORK_FAILED.
2011-05-28 20:09:04 +00:00
Christopher Faylor beaedec545 * fhandler.cc (handler_base_overlapped::wait_overlapped): Rework to attempt to
properly set errno and bytes read for non-blocking case.  Change to just rely
on res to indicate error conditions.
2011-05-28 18:49:13 +00:00
Christopher Faylor d1dded4d67 * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Don't set io_pending
unless ReadFile has returned an error.  (this is a partial fix, accidentally
checked in)
2011-05-28 18:22:59 +00:00
Christopher Faylor 44d2fc0a45 * autoload.cc: Call _api_fatal in asm.
* child_info.h: Redefine CURR_CHILD_INFO_MAGIC.
(child_info_fork::abort): Rename from handle_failure.  Change arguments.
* cygtls.h (_local_storage::ttybuf): New field.
* dcrt0.cc (vapi_fatal): Split api_fatal.  Add "in forked process" to message
when appropriate.
(api_fatal): Use vapi_fatal.
* devices.h: Make multiple inclusion safe.
(fh_devices): Add FH_CONS* stuff.  Reorder slightly.
(device): Eliminate anonymous union.  Add more ways to access minor/major.
(device::setunit): Accommodate no-longer-anonymous union.
(device::is_fs): Ditto.
(device::is_fs_special): Ditto.
(device::major): New function.
(device::minor): Ditto.
(device::is_device): New function.
(device::not_device): Ditto.
(device::operator int): New operator.
(device::operator fh_devices): Ditto.
(device::operator bool): Ditto.
(device::operator DWORD): Ditto.
(device::operator =): Ditto.
(isproc_dev): New function.
(isprocsys_dev): Ditto.
(iscons_dev): Ditto.
(istty_slave_dev): Ditto.
* devices.in: Add new "/dev/cons*" strings.  Accommodate no-longer-anonymous
union throughout.
(BRACK): Use more precise method for initialization.
* devices.cc: Regenerate.
* dtable.cc (dtable::stdio_init): Use get_cttyp instead of get_tty.
(dtable::find_archetype): Use new DWORD operator in device to test archetypes.
(dtable::init_std_file_from_handle): Use different method to initialize 'dev'.
Adapt to different ctty handling and accommodate /dev/cons*.
(fh_alloc): Accommodate no-longer-anonymous union.  Adapt to new /dev/cons*.
(build_fh_pc): Make debugging output more useful.
* exceptions.cc (ctrl_c_handler): Use get_cttyp instead of get_tty.
* external.cc (fillout_pinfo): Accommodate new cons* stuff.
* fhandler.cc (fhandler_base::read): Eliminate is_slow() test.
* fhandler.h (fhandler_base::*): Adapt to changes in device.h.
(fhandler_*::is_slow): Delete.
( fhandler_proc::get_proc_fhandler): Return fh_devices type.
* fhandler_console.cc (open_shared_console): New function.
(console_unit): New class.
(console_unit::console_unit): New constructor.
(enum_windows): New function.  Declare as friend to console_unit.
(fhandler_console::set_unit): New function.
(fhandler_console::get_tty_stuff): Call set_unit to set the unit number and
determine if initialization is needed.  Eliminate flags parameter.
(tty_list::get_cttyp): Rename (sorta) from get_tty.  Return pointer to correct
tty_min.
(fhandler_console::open): Adapt to elimination of argument to get_tty_stuff.
(fhandler_console::output_tcsetattr): Properly detect error condition.
(fhandler_console::fixup_after_fork_exec): Adapt to get_tty_stuff() setting tc
automatically.
* fhandler_proc.cc: Use FH_BAD rather than 0 throughout where using fh_devices
enum.
(fhandler_proc::get_proc_fhandler): Return fh_devices.  Adapt to devices.h
changes.
* fhandler_process.cc: Adapt to devices.h changes.  Use FH_BAD rather than 0
throughout where using fh_devices enum.
* fhandler_procnet.cc: Ditto.
* fhandler_procsys.cc: Ditto.
* fhandler_procsysvipc.cc: Ditto.
* fhandler_tape.cc (fhandler_dev_tape::fhandler_dev_tape): Ditto.
* fhandler_termios.cc (handler_termios::bg_check): Use tc->ttyname() rather
than assuming that we can construct a tty.
* fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Just return
get_minor() of dev.
(fhandler_pty_master::process_slave_output): Add slightly more debugging info.
(fhandler_tty_slave::fhandler_tty_slave): Change name from ntty to unit.
(fhandler_pty_master::open): Ditto.
(fhandler_tty_slave::ioctl): Adapt to change which causes ctty to represent a
complete device.
(fhandler_tty_master::init_console): Add debugging for failure path.
(fhandler_pty_master::setup): Use get_unit() to retrieve unit number rather
than relying on raw ntty.
(fhandler_pty_master::setup): Ditto.
* fhandler_virtual.h (virt_tab_t): Redefine fhandler as fh_devices.
* fork.cc: Remove obsolete vfork stuff.
(frok::child): Don't assume that a ctty == 0 is valid.
* mount.cc (mount_info::conv_to_win32_path): Adapt to device struct changes.
(mount_info::conv_to_win32_path): Ditto.
* path.cc (path_conv::check): Retrive major/minor numbers via a method rather
than accessing them directly from device.  Rely on dev operators to
set/retrieve device information as required by device struct change.
* path.h (isproc_dev): Move to devices.h.
(isprocsys_dev): Ditto.
(isvirtual_dev): Ditto.
(path_conv:{isdevice,isfifo,isspecial,iscygdrive,issocket,get_devn,get_unitn}):
Use device methods to access/manipulate devices.
* pinfo.cc (pinfo::exit): Don't assume that ctty == 0 is valid.  Use iscons_dev
to determine if a device is a console.
(_pinfo::_ctty): Use device::parse to generate tty/cons name.
(_pinfo::set_ctty): Don't assume that ctty == 0 is valid.  Remove redundant
info from debugging.
* shared.cc (offsets): Remove console offset.
* shared_info.h (shared_locations): Ditto.
* syscalls.cc (umask): Use device methods to manipulate device information.
(ctermid): Use device::parse to generate term device name.
* tlsoffsets.h: Regenerate.
* tty.cc (ttyslot): Return minor number of ctty since ctty now represents a
full device.
(tty::create_master): Set ctty to a complete device.
(tty_list::attach): Rework to detect new /dev/cons* stuff.
(tty_list::terminate): Adapt to changes to ctty.
(tty_list::init): Adapt to change to setntty - pass in device major number.
(tty::exists): Use get_unit() to retrive tty unit number.
(tty::open_mutex): Ditto.
(tty::open_inuse): Ditto.
(tty::create_inuse): Ditto.
(tty::get_event): Ditto.
(tty_min::ttyname): Define new function.
* tty.h (tty_min::ntty): Redefine as fh_devices.
(tty::exists): Use get_unit() to retrive tty unit number.
(tty::open_mutex): Ditto.
(tty::open_inuse): Ditto.
(tty::create_inuse): Ditto.
(tty::get_event): Ditto.
(tty_min::ttyname): Declare new function.
(tty::getntty): Declare as const.
(tty_list::operator []): Assure that only minor part of argument is used.
* dll_init.cc (dll_list::alloc): Detect mismatch of data segments early issuing
an explicit error message if necessary.
* heap.cc (heap_init): Adapt to changes from fork->handle_failure to
fork->abort.
* pinfo.h (EXITCODE_FORK_FAILED): New enum.  (from Ryan Johnson)
* sigproc.cc (child_info_fork::abort): Rename from handle_failure.  Change
arguments to allow passing in a printf-like message.
* winsup.h (api_fatal): Delete macro definition.
(api_fatal): Redefine from __api_fatal.
(vapi_fatal): Declare new function.
* include/sys/strace.h (strace_vprintf): Define new macro.
* ntdll.h (_SYSTEM_INFORMATION_CLASS): Add SystemHandleInformation.
2011-05-28 18:17:09 +00:00
Corinna Vinschen bfce73c261 * shared.cc (offsets): Reorder so that console_state is lowest in
memory.  Explain why.
	(open_shared): Accommodate reordering of offsets array.
	* shared_info.h (shared_locations): Reorder SH_SHARED_CONSOLE after
	SH_MYSELF.
2011-05-27 06:11:05 +00:00
Corinna Vinschen 28667da372 * mount.h (MAX_MOUNTS): Raise to 64. 2011-05-26 19:30:00 +00:00
Eric Blake 154fa4d7ef perror: fix POSIX compliance and work with recent newlib change
* cygtls.h (strerror_r_buf): New buffer.
* errno.cc (strerror): Move guts...
(_strerror_r): ...to new function demanded by newlib.
(strerror_r): Don't clobber strerror buffer.
(_user_strerror): Drop unused declaration.
* tlsoffsets.h: Regenerate.
2011-05-25 18:47:32 +00:00
Corinna Vinschen 6215837523 * init.cc (dll_entry): Reinstantiate wow64_test_stack_marker and
previous stack tests.
2011-05-25 11:33:29 +00:00
Corinna Vinschen c57b66f6c3 * posix.sgml (std-notes): Add missing <para>. 2011-05-25 06:10:24 +00:00
Corinna Vinschen d92e95d62c * mount.cc (mount_info::conv_to_win32_path): Remove unused code.
* mount.h (class mount_info): Remove sys_mount_table_counter member.
	* shared_info.h (class shared_info): Ditto.
	(CURR_SHARED_MAGIC): Update.
2011-05-24 15:09:08 +00:00
Corinna Vinschen 0864dd31db * pinfo.h (struct _pinfo): Reduce size of progname array slightly.
Explain why.
2011-05-24 10:03:34 +00:00
Eric Blake 66b729b284 * cygtls.h (strerror_buf): Resize to allow '-'. 2011-05-23 21:03:06 +00:00
Eric Blake 4d95630803 strerror: match recent glibc changes
* errno.cc (strerror): Print unknown errno as int.
(__xpg_strerror_r): Likewise, and don't clobber strerror buffer.
2011-05-23 20:43:06 +00:00
Corinna Vinschen 7d375b5a65 * fhandler_process.cc (thread_info::fill_if_match): Reformat.
(format_process_maps): Ditto.  Fetch pointer to procinfo structure
	from mapped process.  Print info about global shared Cygwin regions.
2011-05-23 08:53:25 +00:00
Corinna Vinschen 15ef1f6caf * fhandler_process.cc (struct dos_drive_mappings): Use malloc/free
rather than cmalloc/cfree.  Check return value from malloc before
	using it.
	(struct heap_info): Ditto.
	(struct thread_info): Ditto.  Rename from stack_info.  Rename members
	and local variables accordingly.
	(thread_info::thread_info): Store stack and TEB addresses.
	(thread_info::fill_if_match): Print "teb" if a TEB address has been
	found.  Special case for WOW64, explain why.
	(format_process_maps): Fetch PEB address.  Print MEM_RESERVE regions
	with equal signs to distinguish them from PAGE_NOACCESS regions.  Fix
	printing of 'p' and 's' to differ between MEM_PRIVATE and MEM_MAPPED
	pages, as on Linux.  Print 'g' instead of 'p for PAGE_GUARD pages.
	Print PEB and SharedUserData area if recognized.
2011-05-21 15:57:16 +00:00
Corinna Vinschen 01b49f835d * miscfuncs.cc (CygwinCreateThread): Fix condition for adding the
guardsize to the stacksize.  Fix accompanying comment.
2011-05-20 19:00:51 +00:00
Corinna Vinschen abb205a9fa * miscfuncs.cc (CygwinCreateThread): Add accidentally missing comment. 2011-05-20 18:15:12 +00:00
Corinna Vinschen 5a755a9471 * fhandler_process.cc (struct heap_info): Change type of base and end
members to char *.  Print "shared" rather than "share".
	(struct stack_info): New class to fetch process stack information.
	(format_process_maps): Initialize and check for stack information.
2011-05-20 18:07:52 +00:00
Corinna Vinschen 6bdbccf7bf * miscfuncs.cc (thread_wrapper): Remove statements added for debugging
purposes.
2011-05-20 07:39:20 +00:00
Corinna Vinschen 89d3c72d51 * child_info.h (CURR_CHILD_INFO_MAGIC): Update.
(class child_info_fork): Remove stacksize, add stackaddr and guardsize
	members.
	* dcrt0.cc (child_info_fork::alloc_stack_hard_way): Partial rewrite
	to regenerate the stack exactly as in the parent.
	(child_info_fork::alloc_stack): Set stackaddr to 0, rather than
	stacksize.
	(dll_crt0_1): Check for stackaddr before changing the stack addresses
	in the TEB.
	* fork.cc (frok::child): Check for stackaddr here.
	(frok::parent): Set ch.stackaddr and ch.guardsize if not called from
	the main thread.
	* init.cc (dll_entry): Replace pointer to NT_TIB with pointer to TEB.
	Fix incorrectly changed address test before removing _my_tls.
	Set StackLimit to NULL on Windows 2000.  Explain why.
	* miscfuncs.cc (struct thread_wrapper_arg): Store stackbase rather
	than stacksize, store commitaddr, remove guardsize.  Store all pointers
	as char * for easier address arithmetic.
	(thread_wrapper): Rewrite to remove OS stack before calling thread
	function.  Add lots of comments to explain what we do.
	(CygwinCreateThread): Reserve our own stack in case we got no
	application stack.  Add comments.
	* ntdll.h (struct _TEB): Extend defintion up to DeallocationStack
	member.
	* thread.cc (pthread_attr::pthread_attr): Use "(size_t) -1"
	rather then 0xffffffff.
	* wincap.h (wincaps::has_stack_size_param_is_a_reservation): New
	element.
	* wincap.cc: Implement above element throughout.
2011-05-20 07:23:11 +00:00
Yaakov Selkowitz 660302eb67 * thread.cc: Mark psiginfo and psignal as available in list of
optional cancellation points.
2011-05-19 23:44:55 +00:00
Yaakov Selkowitz ed516f97a6 * cygwin.din (__fpurge): Export.
* posix.sgml (std-solaris): Add __fpurge.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-19 07:23:29 +00:00
Yaakov Selkowitz a5ffa9b80e * posix.sgml (std-susv4): Remove chroot, futimes, hstrerror.
(std-deprec): Add chroot.
(std-bsd): Add futimes, hstrerror.
(std-notimpl): Add clock_nanosleep, nexttoward, nexttowardf.
Remove initstate, which is implemented and listed in std-susv4.
2011-05-18 21:46:54 +00:00
Yaakov Selkowitz d470b53c98 * cygwin.din (error): Export.
(error_at_line): Export.
(error_message_count): Export.
(error_one_per_line): Export.
(error_print_progname): Export.
* errno.cc (error_message_count): Define.
(error_one_per_line): Define.
(error_print_progname): Define.
(_verror): New static function.
(error): New function.
(error_at_line): New function.
* posix.sgml (std-gnu): Add error, error_at_line.
* include/error.h: New header.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-18 01:25:41 +00:00
Yaakov Selkowitz c8ce54290d * cygwin.din (clock_getcpuclockid): Export.
(pthread_getcpuclockid): Export.
* hires.h (PID_TO_CLOCKID): New macro.
(CLOCKID_TO_PID): New macro.
(CLOCKID_IS_PROCESS): New macro.
(THREADID_TO_CLOCKID): New macro.
(CLOCKID_TO_THREADID): New macro.
(CLOCKID_IS_THREAD): New macro.
* ntdll.h (enum _THREAD_INFORMATION_CLASS): Add ThreadTimes.
* posix.sgml (std-notimpl): Add clock_getcpuclockid and
pthread_getcpuclockid from here...
(std-susv4): ... to here.
(std-notes): Remove limitations of clock_getres and clock_gettime.
Note limitation of timer_create to CLOCK_REALTIME.
* sysconf.cc (sca): Set _SC_CPUTIME to _POSIX_CPUTIME, and
_SC_THREAD_CPUTIME to _POSIX_THREAD_CPUTIME.
* thread.cc (pthread_getcpuclockid): New function.
* timer.cc (timer_create): Set errno to ENOTSUP for CPU-time clocks.
* times.cc (clock_gettime): Handle CLOCK_PROCESS_CPUTIME_ID and
CLOCK_THREAD_CPUTIME_ID.
(clock_getres): Ditto.
(clock_settime): Set errno to EPERM for CPU-time clocks.
(clock_getcpuclockid): New function.
* include/pthread.h (pthread_getcpuclockid): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-17 17:08:10 +00:00
Corinna Vinschen 5e3af166d7 * miscfuncs.cc (thread_wrapper): Remove unused _cygtls record.
* mmap.cc (is_mmapped_region): Avoid crash if no mmaps exist.
2011-05-17 15:37:01 +00:00
Corinna Vinschen 553f08059b * globals.cc (__getlogin_username): Remove.
* uinfo.cc (getlogin_r): Fetch username from cygheap.
	(getlogin): Add static buffer username and fetch username from
	getlogin_r.
2011-05-16 17:58:21 +00:00
Corinna Vinschen bdc00a0d85 * cygtls.h (struct _local_storage): Remove unused members rarg and
_localtime_buf.  Remove username in favor of a global buffer.  Reorder
	slightly to keep the net.cc stuff together.
	* globals.cc (__getlogin_username): New global char buffer.
	* tlsoffsets.h: Regenerate.
	* uinfo.cc (getlogin): Copy username into __getlogin_username.
2011-05-16 15:12:35 +00:00
Corinna Vinschen 883ea27df0 * heap.cc (heap_init): Rewrite initial heap allocation to use addresses
beyond 0x20000000.  Explain why and how.
	* shared.cc (shared_info::heap_slop_size): Remove.
	* shared_info.h (class shared_info): Remove heap_slop_inited and
	heap_slop members.  Remove heap_slop_size declaration.
	(CURR_SHARED_MAGIC): Update.
	* wincap.cc: Throughout, drop heapslop.
	* wincap.h (struct wincaps): Drop heapslop.
2011-05-16 10:27:14 +00:00
Corinna Vinschen 6d6cfa4840 * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Check if the
requested stack is application-provided within the user heap or an
	mmapped region.  If so, just use it.  Add comment to explain why.
	* miscfuncs.cc (thread_wrapper): If an application-provided stack
	has been given, implement cygtls area at the stackbase.  Fix comment.
	* mmap.cc (is_mmapped_region): New function.
	* winsup.h (is_mmapped_region): Declare.
2011-05-16 09:55:18 +00:00
Corinna Vinschen daa69fff5b * miscfuncs.cc (thread_wrapper): Add comments to assembler code. 2011-05-15 19:04:41 +00:00
Corinna Vinschen cdb4231369 * cygwin.din (pthread_attr_getguardsize): Export.
(pthread_attr_setguardsize): Export.
	(pthread_attr_setstack): Export.
	(pthread_attr_setstackaddr): Export.
	* init.cc (dll_entry): Remove wow64_test_stack_marker.  Check for
	unusual stack address by testing stack addresses from current TEB.
	Check validity of _my_tls by testing if it's within the stack as
	given in current TEB.
	* miscfuncs.cc (struct thread_wrapper_arg): New structure used to
	push all required information to thread_wrapper function.
	(thread_wrapper): Wrapper function for actual thread function.
	If an application stack has been given, change %ebp and %esp so that
	the thread function runs on that stack.  If the thread has been created
	by CygwinCreateThread, set up the POSIX guard pages if necessary.
	(CygwinCreateThread): New function.
	* miscfuncs.h (CygwinCreateThread): Declare.
	* ntdll.h (struct _TEB): Define all members up to Peb.
	* posix.sgml (std-susv4): Move pthread_attr_getguardsize,
	pthread_attr_setguardsize and pthread_attr_setstack here.
	(std-deprec): Add pthread_attr_setstackaddr.
	* sysconf.cc (sca): Set _SC_THREAD_ATTR_STACKADDR to
	_POSIX_THREAD_ATTR_STACKADDR.
	* thread.cc (pthread::precreate): Copy pthread_attr stackaddr and
	guardsize members.
	(pthread::create): Call CygwinCreateThread.
	(pthread_attr::pthread_attr): Initialize guardsize.
	(pthread_attr_setstack): New function.
	(pthread_attr_setstackaddr): New function.
	(pthread_attr_setguardsize): New function.
	(pthread_attr_getguardsize): New function.
	(pthread_getattr_np): Copy attr.guardsize.
	* thread.h (pthread_attr): Add member guardsize.
	* include/pthread.h (pthread_attr_getguardsize): Declare.
	(pthread_attr_setguardsize): Declare.
	* include/cygwin/version.h: Bump API minor number.
2011-05-15 18:49:40 +00:00
Corinna Vinschen b4966f9139 * fhandler_process.cc (struct heap_info::heap): Convert base to
uintptr_t.  Add heap_id, end, flags members.
	(heap_info::heap_vm_chunks): Rename from heaps.
	(heap_info::heap_info): Rearrange using RtlQueryProcessDebugInformation
	to get information of heap virtual memory blocks.  Store heap id and
	flags, as well as end address of each block.
	(heap_info::fill_if_match): Check incoming base address against full
	address range of heap chunks.  Convert flag values in extra heap
	information.
	(format_process_maps): Change order so that heap check is done before
	MEM_MAPPED check since there are shareable heaps.
	* ntdll.h (PDI_HEAP_BLOCKS): Define.
	(HEAP_FLAG_NOSERIALIZE): Define.
	(HEAP_FLAG_GROWABLE): Define.
	(HEAP_FLAG_EXCEPTIONS): Define.
	(HEAP_FLAG_NONDEFAULT): Define.
	(HEAP_FLAG_SHAREABLE): Define.
	(HEAP_FLAG_EXECUTABLE): Define.
	(HEAP_FLAG_DEBUGGED): Define.
	(struct _DEBUG_HEAP_ARRAY): Define.
	(struct _DEBUG_HEAP_BLOCK): Define.
2011-05-13 06:50:20 +00:00
Corinna Vinschen 4fda571831 Based on newlib patch to strptime by Peter Rosin <peda@lysator.liu.se>:
* libc/time/strptime.c (is_leap_year): New static function.
	(first_day): Ditto.
	(__strptime): Fill in tm_yday when all of tm_year, tm_mon and tm_mday
	are updated. Fill in tm_mon, tm_mday and tm_wday when both of tm_year
	and tm_yday are updated.
2011-05-12 13:44:54 +00:00
Yaakov Selkowitz 205b82080b * fhandler_proc.cc (format_proc_meminfo): Rewrite to use sysinfo().
Support RAM and swap space larger than 4GB.
Remove output elements not found with modern Linux kernels.
(format_proc_swaps): Support paging files larger than 4GB.
2011-05-12 11:13:02 +00:00
Corinna Vinschen 2fade21617 * autoload.cc: Remove useless comment. 2011-05-11 13:33:17 +00:00
Corinna Vinschen 31ddf45dd8 * autoload.cc (EnumProcessModules): Remove.
* dlfcn.cc (dlopen): Make sure errno is set if an error occurs.
	(dlsym): Rewrite using RtlQueryProcessDebugInformation instead of
	EnumProcessModules.
	* ntdll.h (struct _DEBUG_MODULE_ARRAY): Define.
	(RtlCreateQueryDebugBuffer): Declare.
	(RtlDestroyQueryDebugBuffer): Declare.
	(RtlQueryProcessDebugInformation): Declare.
2011-05-11 13:25:27 +00:00
Corinna Vinschen b27800ad45 * autoload.cc (GetModuleFileNameExW): Remove.
* autoload.cc (GetModuleInformation): Remove.
2011-05-11 10:41:03 +00:00
Corinna Vinschen 76f1b21604 * autoload.cc (QueryWorkingSet): Remove. 2011-05-11 10:34:27 +00:00
Corinna Vinschen 8285dae540 * fhandler_process.cc (format_process_maps): Rework to report
all mapped address space in a process (committed or reserved),
	identifying the nature of the mapping (mapped file/image, heap,
	shared memory) when possible.
	(dos_drive_mappings): New helper classes.
	(heap_info): Ditto.
	* ntdll.h (struct _MEMORY_SECTION_NAME): Define.
2011-05-11 10:31:22 +00:00
Corinna Vinschen 34a6eeabff * autoload.cc (GetProcessMemoryInfo): Remove.
* resource.cc (fill_rusage): Call NtQueryInformationProcess rather than
	GetProcessMemoryInfo to drop a psapi dependency.
2011-05-11 09:07:20 +00:00
Corinna Vinschen 933d2af50d * fhandler_socket.cc (get_inet_addr): Rearrange for better readability.
Make waiting loop interruptible and cancelable.  Check for SYSTEM DOS
	flag before reading the file.  Change return value to return 0 on
	success, SOCKET_ERROR on failure.
	(fhandler_socket::bind): Only set R/O DOS flag on filesystems not
	supporting ACLs.
	(fhandler_socket::connect): Accommodate changed return values from
	get_inet_addr.  Use SOCKET_ERROR instead of -1.
	(fhandler_socket::sendto): Accommodate changed return values from
	get_inet_addr.
	* syslog.cc (connect_syslogd): Ditto.
2011-05-11 08:20:17 +00:00
Christian Franke 3bcc74a9ae * security.cc (check_registry_access): Handle missing
security descriptor of HKEY_PERFORMANCE_DATA.
2011-05-10 17:19:37 +00:00
Corinna Vinschen b6151db104 * lc_msg.h: Regenerate. 2011-05-10 16:43:34 +00:00
Corinna Vinschen c29e693388 * fhandler_proc.cc (format_proc_uptime): Don't call GetSystemInfo.
Fetch CPU count from wincap.
	(format_proc_stat): Ditto.
	* globals.cc (system_info): Move to wincap.
	* heap.cc (heap_init): Fetch page size from wincap.
	* syscalls.cc (getpagesize): Fetch allocation granularity from wincap.
	(getsystempagesize): Fetch page size from wincap.
	* wincap.cc (wincap_2003): Default is_server to false.
	(wincapc::init): Call GetSystemInfo here.  Always set is_server value.
	* wincap.h (class wincapc): Add system_info as private member.
	(wincapc::cpu_count): New public method.
	(wincapc::page_size): Ditto.
	(wincapc::allocation_granularity): Ditto.
2011-05-10 15:39:02 +00:00
Corinna Vinschen e0d1c52693 * environ.cc (set_chunksize): Remove.
(parse_thing): Remove forkchunk entry.
	* fork.cc (child_copy): Drop handling external chunksize setting.
	* wincap.cc: Througout, drop chunksize.
	(wincapc::set_chunksize): Remove.
	* wincap.h (struct wincaps): Drop chunksize and declaration of
	set_chunksize.
2011-05-10 10:17:30 +00:00
Yaakov Selkowitz 6758d2a3aa * times.cc (settimeofday): Add EFAULT handler.
Set errno to EINVAL if tv.tv_nsec is invalid, and to EPERM if
SetSystemTime fails.  Return -1 in case of failure, all for
compatibility with BSD and Linux.
(clock_settime): New function.
* cygwin.din (clock_settime): Export.
* posix.sgml (std-susv4): Add clock_settime.
Move clock_setres from here...
(std-deprec): ... to here.
(std-notes): Correct limitation of clock_setres to only CLOCK_REALTIME.
Add limitation of clock_settime to only CLOCK_REALTIME.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-09 08:57:46 +00:00
Corinna Vinschen b6a46e417b * registry.cc (get_registry_hive_path): Change system_printf to
debug_printf.
	(load_registry_hive): Ditto.
2011-05-07 18:56:39 +00:00
Christopher Faylor c395d22876 * fhandler.h (fhandler_base::close_with_arch): Make non-virtual.
(fhandler_base::open_fs): Move closer to it's close counterpart.
2011-05-06 20:22:45 +00:00
Christopher Faylor f4c566233f * fhandler.cc (fhandler_base::dup): Avoid duping a handle when an fhandler has
an archetype.
* fhandler_console.cc (fhandler_console::invisible_console): Move to the top.
(fhandler_console::set_close_on_exec): Don't set close-on-exec on handle since
it's an archetype and you don't know how many things could be using it.
2011-05-06 20:12:20 +00:00
Christopher Faylor b66dba56c5 * fhandler.h (fhandler_dev_dsp): Cosmetic change.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Put back
Sleep(10) for tty_master case.
* sigproc.cc (stopped_or_terminated): Don't consider a pid which has been
reaped to be terminated.
2011-05-06 19:13:22 +00:00
Yaakov Selkowitz 2f52cad971 * sysconf.cc (sysinfo): New function.
* cygwin.din (sysinfo): Export.
* posix.sgml (std-gnu): Add sysinfo.
* include/sys/sysinfo.h (struct sysinfo): Define.
(sysinfo): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-06 18:53:21 +00:00
Corinna Vinschen cc718e26c6 * libc/minires-os-if.c (get_dns_info): Drop printing uninitialized
value of dwRetVal in debug output.
2011-05-06 18:43:37 +00:00
Corinna Vinschen a4e5706eb2 * fhandler.h (fhandler_socket::read): Declare.
(fhandler_socket::write): Declare.
	* fhandler_procsys.cc (fhandler_procsys::read): Add FIXME comment.
	(fhandler_procsys::write): Ditto.
	* fhandler_socket.cc (fhandler_socket::read): New method.
	(fhandler_socket::write): New method.
	* syscalls.cc: Rearrange order of read/write functions.
	(read): Call fhandler read method directly instead of just readv.
	(readv): Remove EINTR loop.  This is done in all affected fhandler's
	now.
	(write): Call fhandler write method directly instead of just writev.
	Fix debug output.
2011-05-06 10:56:37 +00:00
Christopher Faylor 92ddb74290 * cygheap.cc (cygheap::close_ctty): Close ctty via close_with_arch().
* debug.cc (close_handle): Call debugger on failure.
* devices.in (device::tty_to_real_device): Delete.
* devices.h (device::tty_to_real_device): Ditto.
* devices.cc: Regenerate.
* dtable.cc: Delete old ifdef'ed vfork code.
(dtable::release): Don't handle archetype here.
(dtable::init_std_file_from_handle): Consolidate console tests.  Generate
major/minor for tty ASAP.  Fix incorrect setting of DEV_TTYS* for serial.
(fh_alloc): New function derived from build_fh_pc.  Pass current tty when
building tty.
(build_pc_pc): Use fh_alloc to create.  Set name from fh->dev if appropriate.
Generate an archetype or point to one here.
(dtable::dup_worker): Deal with archetypes.  Rely on = operator copying whole
class rather than just fhandler_base.
(dtable::fixup_after_exec): Call close_with_arch to handle closing of fhandlers
with archetypes.
* fhandler.cc (fhandler_base::operator =): Call memcpy with fhandler's size()
rather than sizeof fhandler_base.
(fhandler_base::open_with_arch): New function.  Handles opening of fhandler's
with archetypes, dealing with usecounts, etc.
(fhandler_base::close_with_arch): Ditto for close.
* fhandler.h: Many changes for archetypes.
(fhandler_base::set_name): Set both normalized path and regular path.
(fhandler_base::open_with_arch): New function.
(fhandler_base::open_setup): Ditto.
(fhandler_base::use_archetype): Ditto.
(fhandler_base::_archetype_usecount): Ditto.
(fhandler_*::size): Ditto.
(fhandler_dev_tape::open): Remove virtual decoration.
(fhandler_console::use_archetype): New function.  Return true.
(fhandler_console::open_setup): New function.
(fhandler_console::dup): Delete.
(fhandler_tty_slave::fhandler_tty_slave): Redeclare to take an argument.
(fhandler_tty_slave::use_archetype): New function.  Return true.
(fhandler_tty_slave::cleanup): New function.
(fhandler_pty_master::use_archetype): New function.  Return true.
(fhandler_pty_master::cleanup): New function.
(fhandler_pty_master::is_tty_master): New function.  Return false.
(fhandler_tty_master::is_tty_master): New function.  Return true.
(fhandler_dev_dsp::fhandler_dev_dsp): New function.  Return true.
(report_tty_counts): Only report on archetype's usecount if there is one.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Remove handling of
setsid, set_ctty, set_flags, and manage_console_count.
(fhandler_console::open_setup): New function.  Implement functionality removed
from get_tty_stuff.
(fhandler_console::dup): Delete.
(fhandler_console::output_tcsetattr): Set errno on error.
(fhandler_console::fhandler_console): Set device early.
(fhandler_console::init): Use open_with_arch to open console handles.
(fhandler_console::fixup_after_fork_exec): Nuke most of the stuff for dealing
with console handles.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Remove archetype handling.
(fhandler_dev_dsp::write): Ditto.
(fhandler_dev_dsp::read): Ditto.
(fhandler_dev_dsp::close): Ditto.
(fhandler_dev_dsp::dup): Ditto.
(fhandler_dev_dsp::ioctl): Ditto.
(fhandler_dev_dsp::fixup_after_fork): Ditto.
(fhandler_dev_dsp::fixup_after_exec): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Add a little
more debugging.
(fhandler_tty_common::__release_output_mutex): Ditto.
(fhandler_pty_master::process_slave_output): Ditto.  Don't do signal handling
or pthread_cancel handling in the tty master thread.
(process_output): Minor reorg.
(fhandler_tty_slave::fhandler_tty_slave): Set device based on new ntty
argument.
(fhandler_tty_slave::open): Remove archetype handling.  Move some processing
into open_setup().
(fhandler_tty_slave::open_setup): New function.
(fhandler_tty_slave::cleanup): New function.
(fhandler_tty_slave::close): Remove archetype handling.  Move some processing
into cleanup().
(fhandler_tty_slave::init): Rename argument from f to h.  Open device using
open_with_arch().  Remove archetype handling.
(fhandler_pty_master::dup): Ditto.
(fhandler_pty_master::open): Ditto.
(fhandler_pty_master::close): Ditto.  Move some handling to cleanup().
(fhandler_pty_master::cleanup): New function.
(fhandler_tty_master::init_console): Give unique name to captive console
fhandler.
* pinfo.cc (_pinfo::set_ctty): Rename argument from arch to fh.  Eliminate
archetype assumption.
* syscalls.cc (close_all_files): Use close_with_arch for closing.
(open): Use open_with_arch() rather than open().
(close): Use close_with_arch() rather than close().
2011-05-05 22:30:53 +00:00
Corinna Vinschen d8ff96389f * pinfo.h (class push_process_state): New class to push a process state
flag temporarily into myself->process_state.
	* fhandler_console.cc (fhandler_console::read): Add push_process_state
	handler.
	(fhandler_console::write): Call bg_check from here.  Add
	push_process_state handler.
	* fhandler_tty.cc (fhandler_tty_slave::write): Ditto.
	(fhandler_tty_slave::read): Ditto.
	(fhandler_pty_master::write): Ditto.
	(fhandler_pty_master::read): Ditto.
	* syscalls.cc (readv): Remove bg_check call and setting process state.
	(writev): Ditto.
2011-05-05 19:43:04 +00:00
Corinna Vinschen 23db0a41d8 * syscalls.cc (readv): Add myfault handler. Don't check repeatedly
open state of file handler.  Streamline loop.
	(writev): Add myfault handler.
2011-05-05 18:46:38 +00:00
Christopher Faylor 8ea8474947 * fhandler.cc (fhandler_base_overlapped::raw_read): Rename from
read_overlapped.
(fhandler_base_overlapped::raw_e): Rename from write_overlapped.
* fhandler.h (fhandler_*::raw_read): Add reparm decoration.
(fhandler_*::raw_write): Ditto.
(fhandler_base_overlapped::raw_read): Rename from read_overlapped.
(fhandler_base_overlapped::raw_write): Rename from write_overlapped.
(fhandler_pipe::raw_read): Delete.
(fhandler_pipe::raw_write): Ditto.
(fhandler_mailslot::raw_read): Ditto.
* fhandler_fifo.cc (fhandler_fifo::raw_read): Reflect read_overlapped ->
raw_read rename.
(fhandler_fifo::raw_write): Ditto.
* fhandler_mailslot.cc (fhandler_mailslot::raw_read): Delete.
(fhandler_mailslot::raw_write): Reflect read_overlapped -> raw_read rename.
* pipe.cc (fhandler_pipe::raw_read): Delete.
(fhandler_pipe::raw_write): Ditto.
2011-05-05 17:44:42 +00:00
Christopher Faylor b8424c5e9a * fork.cc (fork): Clear PID_REAPED.
* pinfo.cc (pinfo_init): Ditto.
(pinfo::init): Check for PID_REAPED.
* sigproc.cc (stopped_or_terminated): Ditto.
2011-05-05 15:03:54 +00:00
Christopher Faylor 1395dac1d0 * pinfo.cc (_pinfo::exists): Check for PID_REAPED. 2011-05-05 14:46:14 +00:00
Corinna Vinschen 42a668f28a Fix typo. 2011-05-05 13:46:32 +00:00
Corinna Vinschen 2b31bc47a7 * fhandler_disk_file.cc (fhandler_disk_file::pread): Correctly return
with errno set to EBADF if file open mode is incorrect.
	(fhandler_disk_file::pwrite): Ditto.
2011-05-05 13:45:06 +00:00
Corinna Vinschen 392323df55 * fhandler.cc (is_at_eof): Drop static storage class. Drop err
parameter since we don't change the Win32 error here anymore.
	(fhandler_base::raw_read): Accommodate change to is_at_eof.

	* fhandler_disk_file.cc (fhandler_disk_file::pread): In binary mode use
	direct call to NtReadFile, rather than lseek/read.
	(fhandler_disk_file::pwrite): In binary mode use direct call to
	NtWriteFile, rather than lseek/write.
2011-05-05 09:05:04 +00:00
Corinna Vinschen 03406c1ae6 * dcrt0.cc (dll_crt0_1): Reset locale to "C" even when dynamically
loaded.
2011-05-05 07:31:13 +00:00
Corinna Vinschen 192737978e * posix.sgml (std-notimpl): Remove bsd_signal, setcontext, and
swapcontext, marked obsolete in SUSv3 and not present in SUSv4.
2011-05-05 06:48:51 +00:00
Corinna Vinschen 2849cbde54 * fhandler_registry.cc (fhandler_registry::exists): Fix regression
in EACCES handling.
	(fhandler_registry::open): Fix "%val" case.
2011-05-05 06:45:21 +00:00
Christopher Faylor 5069a2b0d9 * signal.cc (_pinfo::kill): Return success on kill(0) only if pid exists or is
in PID_EXITED state.  Report pid 0 when pid does not exist rather than pid -1.
Make debug output reflect actual function call.
* sigproc.cc (stopped_or_terminated): Set process state to reaped when we've
finished waiting for it.
* include/sys/cygwin.h (PID_REAPED): New enum.
2011-05-05 00:31:22 +00:00
Yaakov Selkowitz 2f7a5c89cc * cygwin.din (psiginfo): Export.
(psignal): Export.
(sys_siglist): Export.
* posix.sgml (std-notimpl): Move psiginfo and psignal from here...
(std-susv4): ... to here.
(std-deprec): Add sys_siglist.
* strsig.cc (sys_siglist): New array.
(psiginfo): New function.
* include/cygwin/signal.h (sys_siglist): Declare.
(psiginfo): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-04 22:12:15 +00:00
Christopher Faylor 975757698f * dll_list::detach (dll_list::detach): Avoid doing anything with detach during
a failing fork.
2011-05-04 19:19:46 +00:00
Christopher Faylor 3521d50480 * dll_init.cc (dll_global_dtors): Avoid calling destructors during failing
fork().
2011-05-04 16:02:45 +00:00
Corinna Vinschen 54e4df33a2 * fhandler.h (class fhandler_base): Remove uninterruptible_io status
flag.
	(fhandler_base::ready_for_read): Remove declaration.
	(fhandler_socket::ready_for_read): Ditto.
	(fhandler_pipe::ready_for_read): Ditto.
	(fhandler_tty_master::is_slow): Remove.
	* fhandler_console.cc (fhandler_console::open): Drop setting
	uninterruptible_io.
	* fhandler_serial.cc (fhandler_serial::open): Ditto.
	* fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Ditto.
	(fhandler_tty_master::init_console): Ditto.
	* pipe.cc (fhandler_pipe::fhandler_pipe): Ditto.
	(fhandler_pipe::open): Ditto.
	(_pipe): Ditto.
	* select.cc (fhandler_pipe::ready_for_read): Remove.
	(fhandler_base::ready_for_read): Remove.
	* syscalls.cc (readv): Drop unneeded wait variable.  Remove entire test
	which might lead to calling ready_for_read.  Remove now unused label
	out.
2011-05-04 13:06:10 +00:00
Corinna Vinschen 82fa6b929b * fhandler.h (class fhandler_mailslot): Move down in file and change
parent class to fhandler_base_overlapped.  Remove declaration of
	method write.  Add declaraiotns for raw_read and raw_write.
	* fhandler_mailslot.cc (fhandler_mailslot::fhandler_mailslot): Call
	fhandler_base_overlapped constructor.
	(fhandler_mailslot::fstat): Call fhandler_base_overlapped::fstat.
	(fhandler_mailslot::open): Drop FILE_SYNCHRONOUS_IO_NONALERT flag from
	call to NtOpenFile.
	(fhandler_mailslot::raw_read): New method.
	(fhandler_mailslot::raw_write): Ditto.  Take over length algorithm from
	former write method.
	(fhandler_mailslot::write): Remove.
	(fhandler_mailslot::ioctl): Call fhandler_base_overlapped::ioctl.
2011-05-04 12:56:12 +00:00
Corinna Vinschen 412693ab65 * fhandler.h (fhandler_dev_tape::_lock): Add bool parameter.
* fhandler_tape.cc (lock): Call _lock with false argument.
	(_lock): Take bool cancelable parameter.  Handle O_NONBLOCK.
	Make cancelable if cancelabe parameter is true.
	(fhandler_dev_tape::raw_read): Call _lock with true argument.
	(fhandler_dev_tape::raw_write): Ditto.
2011-05-04 12:23:00 +00:00
Corinna Vinschen 5152a53ade * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add fh member.
(fhandler_dev_dsp::Audio_out::Audio_out): Take pointer to encapsulating
	fhandler_dev_dsp as parameter.
	(fhandler_dev_dsp::Audio_in::Audio_in): Ditto.
	(fhandler_dev_dsp::Audio::Audio): Take pointer to encapsulating
	fhandler_dev_dsp as parameter and store in fh.
	(fhandler_dev_dsp::Audio_out::write): Change return type to int and
	return number of bytes written.  Return -1 if waitforspace returns false
	and no bytes have been written so far.
	(fhandler_dev_dsp::Audio_out::waitforspace): Change return type to bool.
	Handle O_NONBLOCK.  Make waiting loop interruptible and cancelable.
	Return false in any of these cases, otherwise true.
	(fhandler_dev_dsp::Audio_in::read): Set returned nBytes to -1 if
	waitfordata returns false and nothing has been read so far.
	(fhandler_dev_dsp::Audio_in::waitfordata): Change return type to bool.
	Handle O_NONBLOCK.  Make waiting loop interruptible and cancelable.
	Return false in any of these cases, otherwise true.
	(fhandler_dev_dsp::write): Call Audio_out constructor with this as
	parameter.
	(fhandler_dev_dsp::read): Call Audio_in constructor with this as
	parameter.
2011-05-04 11:41:22 +00:00
Christopher Faylor 9d2b7928b5 * thread.h (pthread::static_cancel_self): Mark as noreturn.
(pthread::cancel_self): Ditto.
* thread.cc (pthread::cancel_self): Explicitly use pthread::exit to avoid a
"function returns" error.
2011-05-04 06:16:59 +00:00
Christopher Faylor cdbb272b4c * pinfo.cc (pinfo::pinfo): Set procinfo to NULL to avoid potential cleanup of
uninitialized garbage.  (Suggested by Ryan Johnson)
2011-05-04 06:00:54 +00:00
Corinna Vinschen 781822a646 * select.cc (cygwin_select): Make degenerate case cancelable.
(select_stuff::destroy): New inline method to delete memory taken
	by select_stuff.
	(select_stuff::~select_stuff): Call destroy.
	(select_stuff::wait): Add case to allow canceling select.
	* select.h (select_stuff::destroy): Declare.
	* thread.cc: Mark poll, pselect and poll as cancelable.
2011-05-03 15:58:52 +00:00
Corinna Vinschen c402095aae * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Make
cancelable.  Remove test for main thread, always add signal_arrived
	to waited objects.
2011-05-03 10:11:19 +00:00
Corinna Vinschen 3ff46ba853 * fhandler_tty.cc (fhandler_tty_slave::read): Set WFMO timeout to 0 for
nonblocking case.  Drop useless waiter variable.  Rewrite wait for
	input_available_event to use a switch statement.  Handle timeout and
	failure more gracefully.  Make restartable and cancelable.  Rewrite
	wait for input_mutex to use WFMO and a switch statement.  Handle
	timeout and failure more gracefully.  Make restartable and cancelable.
2011-05-03 07:58:13 +00:00
Christopher Faylor 3f359e3254 * signal.cc (_pinfo::kill): Avoid referencing 'pid' after ESRCH. 2011-05-03 02:03:04 +00:00
Yaakov Selkowitz 705a187ee9 * cygwin.din (pthread_attr_getstack): Export.
(pthread_attr_getstackaddr): Export.
(pthread_getattr_np): Export.
* ntdll.h (enum _THREAD_INFORMATION_CLASS): Add ThreadBasicInformation.
(struct _THREAD_BASIC_INFORMATION): Define.
(NtQueryInformationThread): Declare.
* posix.sgml (std-susv4): Add pthread_attr_getstack.
(std-gnu): Add pthread_getattr_np.
(std-deprec): Add pthread_attr_getstackaddr.
(std-notimpl): Remove pthread_attr_[gs]etstackaddr, as they were
removed from SUSv4.
* thread.cc (pthread_attr::pthread_attr): Initialize stackaddr.
(pthread_attr_getstack): New function.
(pthread_attr_getstackaddr): New function.
(pthread_attr_setstacksize): Return EINVAL if passed size less than
PTHREAD_STACK_MIN, as required by POSIX.
(pthread_getattr_np): New function.
* thread.h (class pthread_attr): Add stackaddr member.
* include/pthread.h (pthread_attr_getstack): Declare.
(pthread_attr_getstackaddr): Declare unconditionally.
(pthread_attr_setstack): Declare inside false conditional for reference.
(pthread_getattr_np): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-03 01:13:37 +00:00
Christopher Faylor 1e92c34ee4 fix typo 2011-05-02 23:11:18 +00:00
Christopher Faylor 2671ba6f3a * Makefile.in: Allow CFLAGS to be overridden from the environment. 2011-05-02 19:14:39 +00:00
Corinna Vinschen 183ad8597c * thread.cc (cancelable_wait): Remove test for main thread.
* fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto.
2011-05-02 18:48:11 +00:00
Corinna Vinschen 27dd7bfbcd * fhndler_tty.cc (andler_pty_master::process_slave_output): Make
interruptible and cancelable.  Fix nonblocking case.
2011-05-02 18:41:10 +00:00
Corinna Vinschen e4f70cddcd * fhandler_console.cc (fhandler_console::read): Make restartable and
cancelable.
2011-05-02 17:38:16 +00:00
Christopher Faylor d85a0c243b * strace.cc (strace::vprntf): Avoid closing unopened handle. 2011-05-02 17:05:10 +00:00
Yaakov Selkowitz 58349d7c9d * sysconf.cc (sca): Set _SC_SPIN_LOCKS to _POSIX_SPIN_LOCKS. 2011-05-02 16:11:06 +00:00
Christopher Faylor 8978381c2a Eliminate trailing whitespace in some files.
* dll_init.cc (dll_list::alloc): Reset 'p' in forked process.
* select.cc (select_stuff::wait): Move cleanup() closer to WFMO to minimize
unavoidable (?) race.
2011-05-02 15:28:35 +00:00
Corinna Vinschen 29b1327208 * fhandler_serial.cc (fhandler_serial::raw_read): Add restartability
after a signal.  Add cancelability.
	(fhandler_serial::raw_write): Wait for write to succeed if O_NONBLOCK
	is not set.  Add signal handling and cancelability.
2011-05-02 10:20:35 +00:00
Corinna Vinschen a91ac4dca9 * fhandler_windows.cc (fhandler_windows::read): Use
pthread::get_cancel_event to fetch thread's cancel event.
	* flock.cc (lf_setlock): Ditto.
	* posix_ipc.cc (ipc_cond_timedwait): Ditto.
	* thread.cc (pthread::get_cancel_event): New static method.
	* thread.h (pthread::get_cancel_event): Declare.
2011-05-01 17:42:41 +00:00
Corinna Vinschen 1112b2c38f * libc/minires-os-if.c (get_dns_info): Remove unnecessary test for
existence of DnsQuery_A.
2011-05-01 14:56:46 +00:00
Corinna Vinschen 5c2be92ec4 Add missing ChangeLog entry:
* fhandler.h (fhandler_windows::is_slow): Remove.
2011-05-01 14:36:17 +00:00
Corinna Vinschen 79e741ef6f Throughout, use user32 UNICODE functions rather than ANSI functions.
* autoload.cc: Convert all definitions for ANSI user32 functions to
	definitions for the corresponding UNICODE function.
	(SendMessageA): Remove.
	(SendNotifyMessageW): Define.
	* fhandler_windows.cc (fhandler_windows::write): Use SendNotifyMessageW
	call rather than SendMessage to make function always return immediately.
	(fhandler_windows::read): Make function interruptible and a cancellation
	point.  Handle O_NONBLOCK.
	* select.cc (peek_serial): Don't wait for signal_arrived here.
	* window.cc (wininfo::winthread): Call CreateWindowExW directly rather
	than CreateWindow wrapper.
2011-05-01 14:35:12 +00:00
Corinna Vinschen c60d0bbe68 * net.cc (fdsock): Drop setting uninterruptible_io to true. 2011-05-01 08:14:40 +00:00
Corinna Vinschen 8b6d43aecf * fhandler.h (fhandler_socket::is_slow): Remove. 2011-05-01 08:01:55 +00:00
Corinna Vinschen 1804be048a * fcntl.cc (fcntl64): Call pthread_testcancel.
* fhandler_socket.cc (fhandler_socket::connect): Ditto.
	(fhandler_socket::accept4): Ditto.
	(fhandler_socket::recvfrom): Ditto.
	(fhandler_socket::recvmsg): Ditto.
	(fhandler_socket::sendto): Ditto.
	(fhandler_socket::sendmsg): Ditto.
	* flock.cc (lf_setlock): Allow to cancel thread running blocking
	file lock.  Try to make code more readable.
	(lockf): Call pthread_testcancel.
	* mmap.cc (msync): Ditto.
	* posix_ipc.cc (ipc_cond_timedwait): Call pthread::static_cancel_self
	rather than pthread_testcancel.
	* select.cc (cygwin_select): Call pthread_testcancel.
	* syscalls.cc (pread): Ditto.
	(pwrite): Ditto.
	(readv): Ditto.
	(writev): Ditto.
	(open): Ditto.
	(close): Ditto.
	(fsync): Ditto.
	* termios.cc (tcdrain): Ditto.
	* thread.cc: Align list of cancellation points with above changes.
	Mark not-implemented functions, too.
	(cancelable_wait): Don't set unused object indices to WAIT_FAILED
	since that could result in wrong behaviour.  Set them to the invalid
	value WAIT_TIMEOUT + 1 instead.
2011-04-30 16:34:48 +00:00
Corinna Vinschen 42faed4128 * thread.h (class pthread): Add bool member canceled.
* thread.cc (pthread::pthread): Initialize canceled to false.
	(pthread::cancel): Set canceled before setting cancel_event.
	(pthread::testcancel): Check for canceled.  Only wait for cancel_event
	if canceled is true.  Explain why.
	(pthread::_fixup_after_fork): Set canceled to false.
2011-04-30 10:20:25 +00:00
Corinna Vinschen e0b0b9e4ff * errno.cc (errmap): Sort. Map ERROR_EXE_MACHINE_TYPE_MISMATCH to
ENOEXEC.
2011-04-29 18:54:23 +00:00
Corinna Vinschen 37e680bb6b * thread.cc: Update comment listing cancellation points per POSIX. 2011-04-29 18:29:26 +00:00
Corinna Vinschen 5735d5f6f4 * advapi32.cc: Add comment.
(EqualSid): Remove.
	(CopySid): Remove.
	(AddAccessAllowedAce): Remove.
	(AddAccessDeniedAce): Remove.
	(MakeSelfRelativeSD): Remove.
	* flock.cc: Replace above functions throughout with their ntdll.dll
	equivalent.
	* sec_acl.cc: Ditto.
	* sec_auth.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.
	* security.h: Ditto.
	(RtlEqualSid): Declare.  Explain why.
	(RtlCopySid): Ditto.
2011-04-29 10:38:12 +00:00
Corinna Vinschen 3e8e0c33c0 * advapi32.cc (AccessCheck): Remove.
(PrivilegeCheck): Remove.
	(OpenThreadToken): Remove.
	* fhandler_tty.cc: Replace above functions throughout with their
	ntdll.dll equivalent.
	* security.cc: Ditto.
2011-04-29 09:48:25 +00:00
Corinna Vinschen bd139e52b4 * ntdll.h (IsEventSignalled): New inline function.
* cygthread.cc (cygthread::terminate_thread): Use IsEventSignalled in
	place of WaitForSingleObject on event with 0 timeout.
	* fhandler.cc (fhandler_base_overlapped::has_ongoing_io): Ditto.
	* fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto.
	(fhandler_fifo::wait): Ditto.
	* fhandler_termios.cc (fhandler_termios::bg_check): Ditto.
	* select.cc (verify_tty_slave): Ditto.
	* thread.cc (pthread::testcancel): Ditto.
2011-04-29 08:27:11 +00:00
Corinna Vinschen 12eac211c9 * advapi32.cc (GetTokenInformation): Remove.
(SetTokenInformation): Remove.
	* grp.cc: Replace above functions throughout with their ntdll.dll
	equivalent.
	* sec_auth.cc: Ditto.
	* syscalls.cc: Ditto.
	* uinfo.cc: Ditto.
2011-04-29 07:34:05 +00:00
Corinna Vinschen 541820d0ee * posix_ipc.cc (ipc_cond_timedwait): Only wait for pthread's
cancel_event if thread's cancelability isn't disabled.
2011-04-29 07:22:07 +00:00
Corinna Vinschen fd04c2f004 * advapi32.cc (SetSecurityDescriptorDacl): Remove.
(SetSecurityDescriptorGroup): Remove.
	(SetSecurityDescriptorOwner): Remove.
	* pinfo.cc: Replace above functions throughout with their ntdll.dll
	equivalent.
	* sec_acl.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.

	* sec_helper.cc (__sec_user): Remove old comment.
2011-04-28 15:54:47 +00:00
Corinna Vinschen 206a6ee9c8 * posix_ipc.cc (ipc_cond_timedwait): Also wait for pthread's
cancel_event, if any.  Call pthread_testcancel if cancel_event has been
	signalled.
2011-04-28 14:44:24 +00:00
Corinna Vinschen 74f9ac5be0 * posix_ipc.cc (ipc_cond_timedwait): Remove pthread_testcancel calls.
(_mq_send): Add pthread_testcancel call at start of function.
	(_mq_receive): Ditto.
2011-04-28 12:36:27 +00:00
Corinna Vinschen 86bf572ef0 * cygerrno.h (geterrno_from_nt_status): Declare.
* errno.cc (geterrno_from_nt_status): Define.
	* flock.cc: Fix copyright dates.
	* ntdll.h (enum _TIMER_TYPE): Define.
	(PTIMER_APC_ROUTINE): Define.
	(NtCancelTimer): Declare.
	(NtCreateTimer): Declare.
	(NtSetTimer): Declare.
	* posix_ipc.cc (ipc_cond_timedwait): Rewrite to make interruptible and
	restartable.  Call pthread_testcancel in case of timeout to enable
	pthread_cancel on waiting thread.  Replace WFMO timeout with waiting
	for a waitable timer.  Explain why.  Replace single call to WFMO with
	two calls, one for the event, one for the mutex.  Don't lock mutex in
	case of error.
	(ipc_cond_signal): Make void function.
	(ipc_cond_close): Ditto.
	(_mq_send): Immediately return -1 in case of error from
	ipc_cond_timedwait.
	(_mq_receive): Ditto.
2011-04-28 12:13:41 +00:00
Corinna Vinschen 1838d97b0a * advapi32.cc (GetSecurityDescriptorDacl): Remove.
(GetSecurityDescriptorGroup): Remove.
	(GetSecurityDescriptorOwner): Remove.
	* sec_acl.cc: Replace above functions throughout with their ntdll.dll
	equivalent.  Remove redundant debug output.
	* sec_auth.cc: Ditto.
	* security.cc: Ditto.
	* uinfo.cc: Ditto.
2011-04-28 09:53:11 +00:00
Corinna Vinschen 1754539e56 * advapi32.cc (InitializeAcl): Remove.
(AddAce): Remove.
	(FindFirstFreeAce): Remove.
	(GetAce): Remove.
	(InitializeSecurityDescriptor): Remove.
	(OpenProcessToken): Remove.
	* dcrt0.cc: Replace above functions throughout with their ntdll.dll
	equivalent.
	* fhandler_tty.cc: Ditto.
	* flock.cc: Ditto.
	* pinfo.cc: Ditto.  Drop unnecessary error handling.
	* sec_acl.cc: Ditto.
	* sec_auth.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.
2011-04-28 09:30:36 +00:00
Corinna Vinschen 158e516b9d * advapi32.cc (InitializeSid): Remove.
(EqualPrefixSid): Remove.
	(GetLengthSid): Remove.
	(GetSidSubAuthority): Remove.
	(GetSidSubAuthorityCount): Remove.
	(GetSidIdentifierAuthority): Remove.
	* fhandler_disk_file.cc: Remove above functions throughout with their
	ntdll.dll equivalent.
	* sec_auth.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.
2011-04-28 08:34:49 +00:00
Corinna Vinschen 41e9c14558 * advapi32.cc (AllocateLocallyUniqueId): Remove.
* fhandler_disk_file.cc (fhandler_base::open_fs): Replace call to
	AllocateLocallyUniqueId with call to NtAllocateLocallyUniqueId;
	* posix_ipc.cc (mq_open): Ditto.  Drop error handling for that call.
	(sem_open): Ditto.
2011-04-28 08:15:56 +00:00
Corinna Vinschen f97612978a * autoload.cc (GetSecurityInfo): Remove.
* ntdll.h (RtlConvertToAutoInheritSecurityObject): Declare.
	(RtlDeleteSecurityObject): Declare.
	(RtlGetControlSecurityDescriptor): Declare.
	(RtlLengthSecurityDescriptor): Declare.
	* security.cc (file_mapping): New global variable.
	(get_file_sd): Rewrite.  Clean up code.  Get rid of GetSecurityInfo
	call.
	(alloc_sd): Call RtlSetControlSecurityDescriptor to set
	SE_DACL_PROTECTED flag.
	(check_file_access): Remove mapping.  Use file_mapping instead.
	(check_registry_access): Rename mapping to reg_mapping.
	* wincap.cc: Througout, drop use_get_sec_info_on_dirs,
	* wincap.h (struct wincaps): Drop use_get_sec_info_on_dirs.
2011-04-28 07:27:51 +00:00
Corinna Vinschen 7054950175 * include/fenv.h: Add missing _FENV_H_ define. 2011-04-24 11:54:06 +00:00
Corinna Vinschen cca89be9ad * registry.cc (reg_key::get_dword): Rename from get_int, use DWORD
rather than int type.  Avoid compiler warning.
	(reg_key::set_dword): Rename from set_int, use DWORD rather than int
	type.  Change return type to NTSTATUS.
	(reg_key::get_string): Change return type to NTSTATUS.
	(reg_key::set_string): Ditto.
	* registry.h: Accommodate above changes.
	* environ.cc (regopt): Test return value of reg_key::get_string as
	NTSTATUS.
	* sched.cc (sched_rr_get_interval): Change local int vars to DWORD.
	Call reg_key::get_dword instead of reg_key::get_int.
	* shared.cc (init_installation_root): Test return value of
	reg_key::get_string as NTSTATUS.
	(shared_info::heap_slop_size): Call reg_key::get_dword rather than
	reg_key::get_int.
	(shared_info::heap_chunk_size): Ditto.
	* shared_info.h (CURR_SHARED_MAGIC): Update.
	(class shared_info): Change heap_chunk and heap_slop to DWORD  values.
2011-04-23 13:15:46 +00:00
Corinna Vinschen a0307f9914 * cygtls.cc (_cygtls::init_thread): Drop setting locals.process_logmask.
* cygtls.cc (_cygtls::remove): Always free mallocated TLS storage on
	thread exit.  Drop freeing locals.process_ident.
	* cygtls.h (struct _local_storage): Remove syslog-related members.
	* syslog.cc (syslog_globals): New static storage for global syslog
	settings.  Use throughout instead of _my_tls.locals.
	(openlog): Set new syslog_globals.process_ident value more carefully.
	* tlsoffsets.h: Regenerate.
2011-04-21 08:10:28 +00:00
Corinna Vinschen 2656876fb3 * include/sys/poll.h: Include signal.h to get definition of sigset_t. 2011-04-21 07:18:42 +00:00
Christopher Faylor 71c17c5402 * cygheap.cc (init_cygheap::close_ctty): Avoid closing console-cttys since they
don't use archetypes and this will just result in double frees.
* dll_init.cc (dll_list::protect): Define.
(dll_list::alloc): Guard list access.
(dll_list::detach): Ditto.
* dll_init.h (dll_list::protect): Declare new muto.
(dll_list::guard): Define/declare function to guard list access.
* fhandler_termios.cc (fhandler_termios::sigflush): Avoid SEGV in pathological
condition of get_ttyp() == NULL.
2011-04-21 00:53:55 +00:00
Christopher Faylor 2f9c27131f * select.cc (serial_cleanup): Make sure that device_specific_pipe is always
deleted regardless of whether it has a unique thread associated with it
(socket_cleanup): Ditto.
(mailslot_cleanup): Ditto.
2011-04-20 15:32:31 +00:00
Corinna Vinschen 12c0f2d909 * devices.h: Renumber internal devices so that FH_PROCESS is part of
the /proc family of virtual devices.
	(FH_PROC_MAX_MINOR): Define.
	* path.h (isproc_dev): Use FH_PROC_MAX_MINOR rather than FH_PROC.
2011-04-20 07:29:10 +00:00
Corinna Vinschen f59c2998a1 Fix spaces 2011-04-20 06:52:57 +00:00
Christopher Faylor 693581e4a4 * select.cc (pipe_cleanup): Make sure that device_specific_pipe is always
deleted regardless of whether it has a unique thread associated with it.
2011-04-20 01:10:54 +00:00
Jon TURNEY 11629685f1 2011-04-02 Jon TURNEY <jon.turney@dronecode.org.uk>
* thread.cc (semaphore::init): We cannot reliably infer anything from
        the existing contents of sem, so merely warn rather than return EBUSY
        if it looks like we are reinitialising a semaphore.
2011-04-19 18:51:20 +00:00
Corinna Vinschen ba6aad1d73 * autoload.cc (GetConsoleWindow): Drop.
(GetSystemWindowsDirectoryW): Drop.
	* fhandler_console.cc (beep): Call GetSystemWindowsDirectoryW instead of
	GetWindowsDirectoryW.
	* uinfo.cc (cygheap_user::env_systemroot): Call
	GetSystemWindowsDirectoryW and convert to multibyte on the fly.
	* winlean.h (GetWindowsDirectoryW): Redefine to something invalid.
	Explain why.
2011-04-19 10:15:09 +00:00
Corinna Vinschen b18cb86be7 * Makefile.in (DLL_IMPORTS): Drop advapi32.dll.
* autoload.cc: Enable autoloading advapi32 functions.
	* environ.cc (regopt): Use wide char arguments in reg_key functions.
	* fhandler_console.cc (beep): Ditto.  Use WCHAR throughout.
	* registry.cc (reg_key): Rewrite reg_key class to use native NT registry
	functions.  Use WCHAR string parameters throughout.  Use PCWSTR rather
	than const WCHAR.  Drop multibyte char functionality.  Drop unused
	methods.
	(get_registry_hive_path): Use RtlQueryRegistryValues to fetch path from
	registry.
	(load_registry_hive): Drop useless check for user hive being available.
	Load hive using NtLoadKey.
	* registry.h: Accommodate above changes.
	* sched.cc (sched_rr_get_interval): Use wide char arguments in reg_key
	functions.
	* shared.cc (init_installation_root): Ditto.
	(shared_info::init_obcaseinsensitive): Use RtlQueryRegistryValues to
	fetch obcaseinsensitive value.
	(shared_info::heap_slop_size): Use wide char arguments in reg_key
	functions.
	(shared_info::heap_chunk_size): Ditto.
	* syscalls.cc (gethostid): Ditto.
	* winsup.h (__WIDE): Define.
	(_WIDE): Define.
	* libc/minires-os-if.c (get_registry_dns_items): Don't fetch values
	from registry.  Just extract them from given UNICODE_STRING parameter.
	(get_registry_dns): Fetch all registry values at once using
	RtlQueryRegistryValues.
2011-04-19 10:02:06 +00:00
Corinna Vinschen cbc26145e8 * net.cc (get_ipv4fromreg_ipcnt): Rearrange to fetch all registry
values at once using RtlQueryRegistryValues.
	(get_ipv4fromreg): Ditto.
2011-04-19 08:59:30 +00:00
Corinna Vinschen e5c91e1627 * fhandler_registry.cc (fhandler_registry::fstat): Use RegQueryInfoKeyW. 2011-04-19 08:45:36 +00:00
Corinna Vinschen f5ab5b84de * fhandler_proc.cc (read_value): Remove definition.
(print): Simplify.
	(format_proc_cpuinfo): Drop useless call to GetSystemInfo.  Rearrange
	to use Rtl registry functions.  Rename dwOldThreadAffinityMask to
	orig_affinity_mask.
2011-04-19 08:39:38 +00:00
Corinna Vinschen 593d0dc50f * localtime.cc (tzload): Don't change global timezone information
when called from gmtime or gmtime_r.
	(tzparse): Ditto.
2011-04-18 19:07:18 +00:00
Corinna Vinschen 1d8170bdfa * cygtls.cc (_cygtls::remove): Always close sockevt handle. 2011-04-18 15:51:54 +00:00
Christopher Faylor ab4c946e4c fix typo 2011-04-18 14:02:02 +00:00
Corinna Vinschen 20a0b8c8e6 * cygwin.din (ppoll): Export.
* poll.cc (ppoll): Implement.
	* posix.sgml (std-gnu): Add ppoll.
	* include/cygwin/version.h: Bump API minor number.
	* include/sys/poll.h (ppoll): Declare.
2011-04-18 12:00:05 +00:00
Corinna Vinschen 0077cd1016 * fhandler_socket.cc (fhandler_socket::evaluate_events): Handle the
FD_CLOSE event specially when called from accept.  Explain why.
	(fhandler_socket::shutdown): Fake success on not-connected socket and
	trigger socket event if the read side of a socket is affected.  Explain
	why.
	* poll.cc (poll): Check for saw_shutdown_read on sockets to generate
	POLLHUP as well.
2011-04-18 11:44:17 +00:00
Corinna Vinschen 7c8126eb3e * Fix various copyrights. 2011-04-18 11:26:37 +00:00
Christopher Faylor 2d077d7c6d * * signal.cc (_pinfo::kill): Set this_process_state when process exists. 2011-04-18 01:46:57 +00:00
Christopher Faylor fdcae03c0f * signal.cc (_pinfo::kill): Return 0 when attempting to test for existence of
an existed process which has not yet been reaped.
2011-04-17 21:45:28 +00:00
Christopher Faylor f4c1f003e3 * cygheap.h (init_cygheap::ctty): Use base class so that console can join in
the fun.
* dtable.cc (dtable::stdio_init): Remove special-case call to set_console_ctty
().
* exceptions.cc (sigpacket::process): Conditionally flush terminal input on
certain signals.
* fhandler.h (fhandler_console::get_tty_stuff): Make non-static.
(fhandler_termios::get_ttyp): Move here.
(fhandler_termios::sigflush): Declare.
(fhandler_tty_common::get_ttyp): Delete.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Pass this as "arch"
argument.
(set_console_ctty): Delete.
(tty_list::get_tty): Just return pointer to shared console region, delaying
get_tty_stuff until open().
(fhandler_console::init): Treat NULL handle as signifying that console should
be opened with O_NOCTTY flag.  Rename handle argument to the more common 'h'.
* fhandler_termios.cc (fhandler_termios::sigflush): Define.
* fhandler_tty.cc (handler_tty_master::init_console): Pass NULL as first
argument to fhandler_console::init.
* pinfo.cc (_pinfo::set_ctty): Change third parameter to fhandler_termios *.
Add extra debugging.
* pinfo.h (_pinfo::set_ctty): Change third parameter to fhandler_termios *.
* sigproc.cc (handle_sigsuspend): Don't special-case non-main threads.
2011-04-17 19:56:25 +00:00
Yaakov Selkowitz 162deed595 * thread.cc (pthread_setschedprio): New function.
* include/pthread.h (pthread_setschedprio): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* cygwin.din (pthread_setschedprio): Export.
* posix.sgml (std-notimpl) Move pthread_setschedprio from here...
(std-susv4) ...to here.
2011-04-15 09:22:14 +00:00
Yaakov Selkowitz 5f6d028db2 * fhandler_proc.cc (proc_tab): Add /proc/swaps virtual file.
(format_proc_swaps): New function.
2011-04-11 02:09:43 +00:00
Christopher Faylor 30a4f5b696 * Makefile.in: Move srcdir definition before others which uses it. 2011-04-07 06:07:21 +00:00
Christopher Faylor 8d777a13fc * dll_init.cc (reserve_at, release_at): New functions.
(load_after_fork): If the DLL was loaded higher than the required address,
assume that it loaded at it's base address and also reserve memory there to
force it to be relocated.
2011-04-06 13:58:00 +00:00
Yaakov Selkowitz ddebf19a2a * include/cygwin/types.h: Move #include <sys/sysmacros.h> to
end of header so that it gets the dev_t typedef.
* include/sys/sysmacros.h (gnu_dev_major, gnu_dev_minor,
gnu_dev_makedev): Prototype and define as inline functions.
(major, minor, makedev): Redefine in terms of gnu_dev_*.
2011-04-05 00:53:17 +00:00
Yaakov Selkowitz 8b09538c94 * include/cygwin/types.h: Move multiple inclusion guards to
beginning and end of header.
2011-04-05 00:50:19 +00:00
Christopher Faylor 3649c742cb * Makefile.in: Move Makefile.common include earlier to fix problems with
relative ${srcdir} path which confuses make.
2011-04-04 15:01:43 +00:00
Corinna Vinschen 6ce541281e Drop NT4 support.
* autoload.cc (DnsQuery_A): Fatal if not available.
	(DnsRecordListFree): Ditto.
	(DsGetDcNameW): Ditto.
	(NetGetAnyDCName): Remove.
	(NetGetDCName): Remove.
	(EnumProcessModules): Fatal if not available.
	(GetModuleFileNameExW): Ditto.
	(GetModuleInformation): Ditto.
	(GetProcessMemoryInfo): Ditto.
	(QueryWorkingSet): Ditto.
	(LsaRegisterLogonProcess): Ditto.
	* fenv.cc (_feinitialise): Drop supports_sse condition.
	* fhandler_disk_file.cc (path_conv::isgood_inode): Fix comment.
	(fhandler_base::fstat_by_name): Drop has_fileid_dirinfo condition.
	(fhandler_disk_file::opendir): Ditto.
	* fhandler_netdrive.cc (fhandler_netdrive::readdir): Fix comment.
	* fhandler_proc.cc (format_proc_partitions): Drop NT4-only code.
	* fhandler_process.cc (get_process_state): Ditto.
	* kernel32.cc (GetWindowsDirectoryW): Remove.
	(GetWindowsDirectoryA): Remove.
	* miscfuncs.cc (nice_to_winprio): Drop NT4-only code.
	* mount.cc (fs_info::update): Fix comments.
	* net.cc (get_2k_ifs): Drop NT4-only code.
	* sec_auth.cc (get_logon_server): Ditto.
	(lsaauth): Drop NT4-specific error handling.
	* security.cc (alloc_sd): Set SE_DACL_PROTECTED unconditionally.
	* select.cc (select_stuff::wait): Always use MWMO_INPUTAVAILABLE.
	(peek_windows): Drop NT4-only condition in call to PeekMessage.
	* syscalls.cc (gethostid): Remove NT4-only workaround.
	* wincap.cc: Througout, drop has_dacl_protect,
	has_broken_if_oper_status, has_process_io_counters,
	has_terminal_services, has_extended_priority_class, has_guid_volumes,
	has_fileid_dirinfo, has_mwmo_inputavailable and supports_sse from
	wincaps.
	(wincap_nt4sp4): Remove.
	(wincap_minimal): Set to wincap_2000.
	(wincapc::init): Rely on availability of OSVERSIONINFOEX structure.
	Treat error from GetVersionEx as fatal.  Treat NT4 as fatal.
	* wincap.h (struct wincaps): Drop has_dacl_protect,
	has_broken_if_oper_status, has_process_io_counters,
	has_terminal_services, has_extended_priority_class, has_guid_volumes,
	has_fileid_dirinfo, has_mwmo_inputavailable and supports_sse flags
	and methods.
	* winlean.h (GetWindowsDirectoryW) Define as GetSystemWindowsDirectoryW.
	(GetWindowsDirectoryA): Define as GetSystemWindowsDirectoryA.
2011-04-04 12:23:36 +00:00
Corinna Vinschen 02dbd9ae87 * dtable.cc (dtable::init_std_file_from_handle): Fix a comment to
reflect the current state.
2011-04-04 11:24:20 +00:00