Commit Graph

6152 Commits

Author SHA1 Message Date
Christopher Faylor 986da7853d * select.cc (cygwin_select): Make sure that poll is called when appropriate. 2011-12-08 06:49:56 +00:00
Christopher Faylor 5025bf330b * dll_init.cc (dll_dllcrt0): Don't try to initialize dll data if we're
dynamically loaded since fork() doesn't work in that scenario anyway.
(dll_dllcrt0_1): Don't accommodate dynamically loaded dlls.
* exceptions.cc (ctrl_c_handler): Don't lock the process; there's too much risk
of deadlock.
* sigproc.cc (_cygtls::remove_wq): Don't try to remove anything from the waitq
if there is obviously nothing there.
* strace.cc (strace::activate): Allow stracing dynamically loaded cygwin1.dll.
2011-12-08 06:17:49 +00:00
Christopher Faylor 069e637c0e * fhandler_termios.cc (tty_min::kill_pgrp): Don't send __SIGSETPGRP since
presumably we are already initialized.
2011-12-08 04:09:22 +00:00
Christopher Faylor d4f8245048 * select.cc (cygwin_select): Add common introducer and leaver debug output.
(select_stuff::poll): Remove unneeded debugging.
2011-12-07 23:14:47 +00:00
Christopher Faylor 13b4946d2a * exceptions.cc (ctrl_c_handler): Remove _my_tls.remove since it can cause
deadlocks during exec and will eventually be handled anyway.
2011-12-07 13:54:54 +00:00
Corinna Vinschen 47de562e7c * spawn.cc (child_info_spawn::worker): Add CREATE_BREAKAWAY_FROM_JOB
to all spawned processes.  Explain why.
2011-12-07 10:48:17 +00:00
Christopher Faylor 9bab9bfeb5 * fhandler_fifo.cc (fhandler_fifo::wait): Fix stupid typo and actually wait for
the handle.
2011-12-07 03:07:25 +00:00
Christopher Faylor 08d944e19f * sigproc.cc (close_my_readsig): New function.
(_cygtls::signal_exit): Close my_readsig via close_my_readsig(), avoiding
communication with the signal pipe.
(wait_sig): Close my_readsig via close_my_readsig().
2011-12-05 15:59:06 +00:00
Corinna Vinschen 8912b2e56f * mmap.cc (mlock): Replace LOCK_VM_IN_WSL with correct MAP_PROCESS.
(munlock): Ditto.
	* ntdll.h: Rearrange to have all preprocessor definitions at the start
	of the file.  Add comments to each definition block.
	(MAP_PROCESS): Rename from LOCK_VM_IN_WSL.
	(MAP_SYSTEM): Rename from LOCK_VM_IN_RAM.
2011-12-05 15:46:26 +00:00
Christopher Faylor 536e00784e correct name of function 2011-12-04 18:40:51 +00:00
Christopher Faylor 79e59d522a * sigproc.cc (cygWFMO): Don't assume that cancellable event is always
available.
* fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::waitforspace): Use cygWFMO
instead of WaitForMultipleObjects.
(fhandler_dev_dsp::Audio_in::waitfordata): Ditto.
* fhandler_fifo.cc (fhandler_fifo::wait): Ditto.
* fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
(fhandler_serial::raw_write): Ditto.
* fhandler_tty.cc (fhandler_pty_slave::read): Ditto.
* select.cc (cygwin_select): Ditto for degenerate case.
2011-12-04 18:32:00 +00:00
Christopher Faylor 4510afa90d * sigproc.h (cygWFMO): Move inside "INSIDE_CYGWIN" #ifdef. 2011-12-04 18:15:36 +00:00
Christopher Faylor 8f937028d9 * exceptions.cc (exception::handle): Drop abbreviation for "exception" since I
never remember what it stands for.
(sig_handle_tty_stop): Remove obsolete call to sig_handle_tty_stop.
(_cygtls::call_signal_handler): Rework to grab signal information from
_main_tls if none is set for _my_tls.  Try harder to keep thread locked.
(reset_signal_arrived): Delete.
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use new cygWFMO call
to wait for an event + standard cygwin stuff.  Modify debug output to
acccomodate new function.
* fhandler_console.cc (fhandler_console::read): Replace WaitForMultipleObjects
with cygWFMO.
* fhandler_socket.cc (get_inet_addr): Add comment.
* gendef (_sigdelayed): Remove call to reset_signal_arrived.
* sigproc.cc (_cygtls::signal_exit): Don't close my_readsig here unless we're
in the signal thread.
(create_signal_arrived): Create signal_arrived as auto-reset so that only one
thread is woken when a signal arrives.
* sigproc.h (cygWFMO): New function.
(reset_signal_arrived): Delete declaration.
2011-12-04 17:58:24 +00:00
Christopher Faylor 69864e48cb * mmap.cc (mlock): Add standard syscall return value debugging output.
(munlock): Ditto.
(posix_madvise): Ditto.
* signal.cc: Remove obsolete sigcatchers stuff throughout.
(sigaction_worker): Add function name parameter and use it to show standard
syscall return value debugging output.  Also add fault protection.
(sigaction): Accommodate extra argument to sigaction_worker.
(siginterrupt): Ditto.
* syscalls.cc (read): Remove obsolete sigcatchers stuff.
(readv): Ditto.
2011-12-03 23:55:21 +00:00
Christopher Faylor 6455755743 fix incorrectly named file in old ChangeLog entry 2011-12-03 23:49:03 +00:00
Corinna Vinschen 447354e13c * mmap.cc (mlock): Drop requesting SE_LOCK_MEMORY_PRIVILEGE. Drop
outdated comment.  Call NtLockVirtualMemory with LOCK_VM_IN_WSL flag.
	(munlock): Drop requesting SE_LOCK_MEMORY_PRIVILEGE.  Call
	NtUnlockVirtualMemory with LOCK_VM_IN_WSL flag.
2011-12-03 23:03:15 +00:00
Christopher Faylor b9aa81491f Throughout, remove extra space after function name from debugging output.
Throughout, change syscalls to report on return values using new %R format
option.
* smallprint.cc (__small_vsprintf): Add parsing for %R to report on return
values and possible errno from syscalls.
* errno.cc (errmap): Add PRIVILEGE_NOT_HELD.
* fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread use
shorter name to reduce debuggging output.
* select.cc (start_thread_pipe): Ditto.
(start_thread_serial): Ditto.
(start_thread_socket): Ditto.
(start_thread_mailslot): Ditto.
* sigproc.cc (talktome): Ditto.
2011-12-03 21:43:27 +00:00
Corinna Vinschen 8b25478267 * fhandler.cc (fhandler_base::open): Fix comment a bit more. 2011-12-03 20:35:36 +00:00
Corinna Vinschen 5687f6834a * fhandler.cc (fhandler_base::open): Fix typos in comment. 2011-12-03 14:21:30 +00:00
Corinna Vinschen a887cf0ef5 * path.cc (conv_path_list): Take cygwin_conv_path_t as third parameter.
Allow all types of CCP conversions.  Accommodate throughout.
	(cygwin_conv_path): Use current ANSI or OEM codepage for WIN_A
	conversions, depending on current file API codepage setting.
	(cygwin_conv_path_list): Allow all CCP conversion types.
	* include/sys/cygwin.h (CCP_CONVTYPE_MASK): Add to cygwin_conv_path_t
	enum for convenience.
2011-12-02 16:06:10 +00:00
Christopher Faylor 26bb3098fd * sigproc.cc (get_proc_lock): Remove extra NULL check. Return false on
failure.
2011-11-29 17:41:01 +00:00
Christopher Faylor 6a28849237 * sync.cc: Fix comment.
* dll_init.cc (dll_list::reserve_space): Use %p rather than %lx to show
reserved space.
2011-11-29 17:26:57 +00:00
Christopher Faylor 480b13a37a * sigproc.cc (remove_proc): Don't terminate the currently executing thread. 2011-11-29 15:34:49 +00:00
Christopher Faylor 806e25759b fix older description 2011-11-29 05:38:12 +00:00
Corinna Vinschen 8ae61a8d6c * external.cc (fillout_pinfo): Store program name as POSIX path in
ep.progname_long.
2011-11-28 17:53:18 +00:00
Corinna Vinschen 9c29e82edb * pinfo.cc (pinfo::exit): Call TerminateProcess to avoid potential
busy loop in ntdll.dll when calling ExitProcess. Only call ExitProcess
	as a fallback.
2011-11-28 16:00:07 +00:00
Christopher Faylor 0e5d7582d5 * init.cc (dll_entry): Revert previous change since it caused inexplicable fork
problems.
2011-11-27 19:00:33 +00:00
Christopher Faylor d8e7e40416 * init.cc (remove): Don't bother calling through thread removal cleanup if we
are exiting.
2011-11-26 19:20:13 +00:00
Christopher Faylor 4ab568c60c * exceptions.cc (stackdump): Make global.
(signal_exit): Move to sigproc.cc.
* sigproc.cc (signal_exit): Move here.  Declare stackdump extern.  Set
my_sendsig to indicate that signals are no longer available.
(my_readsig): Make Static again.
(sig_send): Interpret ERROR_BROKEN_PIPE as ESRCH.  Remove special-case EACCESS
errno setting, just setting errno generally, even for "its_me" case.
2011-11-26 19:14:22 +00:00
Christopher Faylor 1d04c4c6c3 * exceptions.cc (sigpacket::process): Move signal_exit processing into...
(_cygtls::signal_exit): ...here.  Close my_readsig and comment on why.
* pinfo.cc (pinfo::exit): Move sigproc_terminate earlier.  Set exiting flag in
lock_process.
* sigproc.cc (my_readsig): Make global.
* sync.cc (muto::exiting_thread): Delete.
(muto::acquire): Delete #if 0'ed code.
* sync.h (muto::exiting_thread): Delete.
(set_exiting_thread): Ditto.
(lock_process::lock_process): Don't worry about setting the exiting thread
since it had no meaning.
2011-11-26 02:35:49 +00:00
Christopher Faylor e553226cfa missed this in previous checkin 2011-11-24 21:38:17 +00:00
Christopher Faylor ef8bff85be * cygthread.h (cygthread::name): Default name to "main" if we are early in the
process of setting up the DLL and no name is known.
* dcrt0.cc (initial_env): Remove CYGWIN_SLEEP stuff.
(get_cygwin_startup_info): Activate strace here as appropriate.
(dll_crt0_0): Move get_cygwin_startup_info as early as possible to avoid
missing strace output.
* fork.cc (frok::child): Move debugging statement to point where ppid will be
set.
* pinfo.cc (pinfo::thisproc): Remove obsolete call to strace.hello.  Tweak
debug output slightly.
* select.cc (select_stuff::wait): Allow APCS to be triggered while waiting
since we use them now.  Report when that happens.
* sigproc.cc (child_info::child_info): Use strace.active() rather than
strace.attached().
* spawn.cc (child_info_spawn::worker): Only write strace child pid when we know
it's a cygwin process.  Accommodate change to write_child argument list.
* strace.cc (strace::hello): Delete.  Move functionality...
(strace::activate): ...to here.
(mypid): Just use raw GetCurrentProcessId () if myself isn't set.
(strace::write_childpid): Don't wait for subproc_ready.  Remove arg which was
required for it.
* include/sys/strace.h (strace::hello): Delete.
(strace::write_childpid): Delete first argument.
2011-11-24 21:36:53 +00:00
Christopher Faylor 8942ed09ac * child_info.h (CURR_CHILD_INFO_MAGIC): Reset for previous changes.
* dcrt0.cc (get_cygwin_startup_info): Signal readiness when stracing since
strace::write_child relies on it.  Use strace.activate to notify strace
process, passing in arg indicating whether we're forked.
* sigproc.cc (wait_sig): Accommodate new strace::activate argument.
* spawn.cc (child_info_spawn::worker): Oops.  Previous suspended test was
actually correct.  Revert and document.
* strace.cc (strace::activate): Send additional flag indicating whether this is
an attempt to activate a forked process.
(strace::hello): Report on windows pid.
* include/sys/strace.h (strace::strace): Make a dummy.
(strace::activate): Modify declaration to accept an argument.
(strace::write_childpid): Set regparm.
2011-11-24 02:17:55 +00:00
Christopher Faylor 5f38ec4681 * pipe.cc (fhandler_pipe::create): Avoid derefencing a NULL pointer.
* child_info.h (child_info): Reorganize some elements so that the ones which
are initialized in a constructor are all together.
* sigproc.cc (child_info::child_info): Initialize values via the constructor
rather than as C statements and make sure that flags is set to zero initially.
* spawn.cc (child_info_spawn::worker): Use iscygwin() test for determining when
to send strace info since it is more foolproof than checking the suspend state.
2011-11-23 21:58:43 +00:00
Christopher Faylor 9f65451e3e * fhandler.h (fhandler_pipe::create): Rename from the misnamed
"create_selectable".  Change return to DWORD.
(fhandler_pty_common::pipesize): New constant.
* fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Reflect create_selectable
name change.
* miscfuncs.cc (CreatePipeOverlapped): Ditto.
* pipe.cc (fhandler_pipe::create): Ditto.
(fhandler_pipe::create): Rename from the misnamed "create_selectable".  Return
DWORD.  Only set pipe size to default when it is passed in as zero.
* fhandler_tty.cc (fhandler_pty_master::setup): Ditto.  Use
fhandler_pty_common::pipesize rather than a raw constant.
* tty.cc (tty::not_allocated): Ditto.
* sigproc.cc (sigproc_init): Use create_selectable to create the signal pipe to
get a more appropriate message based pipe.
2011-11-23 18:56:57 +00:00
Christopher Faylor cc07096c5c * sigproc.cc (remove_proc): Don't do busy loop when exiting since it doesn't
matter.
2011-11-21 21:09:33 +00:00
Christopher Faylor 15660c23ab * sigproc.cc (remove_proc): Don't do busy loop when execing since thread could
have been terminated prior to setting flag.
* signal.cc (sigwaitinfo): Zero event before closing to signal other threads
that it is no longer available.
2011-11-21 19:13:30 +00:00
Corinna Vinschen c5785504f8 * shared.cc (get_shared_parent_dir): Use global shared_parent_dir
instead of local dir variable and create handle not inheritable to
	avoid accumulating stray handles in child processes.
	(get_session_parent_dir): Ditto with session_parent_dir variable.
2011-11-18 17:38:04 +00:00
Corinna Vinschen 4cc465db9a * shared.cc (shared_info::create): Open global shared data section
non-inheritable to avoid accumulating stray handles in child processes.
2011-11-17 22:08:14 +00:00
Christopher Faylor 7b2740dda3 * child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
(cygheap_exec_info::nchildren): Move from child_info_spawn.
(cygheap_exec_info::cchildren): Ditto.
(cygheap_exec_info::record_children): Declare new function.
(cygheap_exec_info::reattach_children): Ditto.
(cygheap_exec_info::alloc): Ditto.
(child_info_spawn::nchildren): Move to cygheap_exec_info.
(child_info_spawn::cchildren): Ditto.
* sigproc.cc (cygheap_exec_info::alloc): Define new function.
(child_info_spawn::cleanup): Accommodate move of children info to
cygheap_exec_info.
(cygheap_exec_info::record_children): Define new function.
(cygheap_exec_info::reattach_children): Ditto.
(child_info_spawn::record_children): Use cygheap_exec_info function to
accomplish this task.
(child_info_spawn::reattach_children): Ditto.
* spawn.cc (child_info_spawn::worker): Allocate moreinfo using
cygheap_exec_info::alloc.
* dcrt0.cc (child_info_fork::alloc_stack_hard_way): Use abort for the error to
avoid a retry.
2011-11-16 04:09:33 +00:00
Christopher Faylor f32d96ff99 * pinfo.cc (_pinfo::dup_proc_pipe): Fatalize a warning when debugging. 2011-11-14 18:22:46 +00:00
Christopher Faylor 18eaa70b5b Remove erroneously checked-in debugging statements.
* cygheap.cc (cygheap_fixup_in_child): Here.
* debug.cc (delete_handle): Here.
* sigproc.cc (child_info_spawn::cleanup): Here.
* spawn.cc (child_info_spawn::worker): Here.
2011-11-14 01:45:42 +00:00
Christopher Faylor 466e694855 update copyrights 2011-11-14 01:37:02 +00:00
Christopher Faylor 56a1971526 Throughout use "have_execed" macro rather than "hExeced" global handle.
Throughout rename _PROC_* to _CH_*.
* child_info.h: Include "pinfo.h".
(child_info_types): Rename _PROC_* -> _CH_* to avoid confusion with similarly
named constants.
(_PROC_*): Delete unneeded aliases.
(PROC_*): Ditto.
(CURR_CHILD_INFO_MAGIC): Ditto.
(cchildren): Define using "pinfo_minimal".
(child_info::set_saw_ctrl_c): Move to
(child_info_spawn::set_saw_ctrl_c): Here.
(child_info_spawn::lock): New field.
(child_info_spawn::hExeced): Ditto.
(child_info_spawn::ev): Ditto.
(child_info_spawn::~child_info_spawn): Move to sigproc.cc.
(child_info_spawn::child_info_spawn): Ditto.
(child_info_spawn::cleanup): Declare new function.
(child_info_spawn::set_saw_ctrl_c): Move to this class.  Set flag only when
execed and return true when we have set the flag.
(child_info_spawn::child_info_spawn::signal_myself_exited): New function.
(child_info_spawn::wait_for_myself): Ditto.
(child_info_spawn::has_execed_cygwin): Ditto.
(child_info_spawn::has_execed): Ditto.  Replaces "hExeced" test.
(child_info_spawn::operator HANDLE&): New operator.
(child_info_spawn::worker): Define old "spawn_guts" as class member.
(ch_spawn): Declare.
(have_execed): Define.
(have_execed_cygwin): Ditto.
* cygheap.h: Update comment.
* dcrt0.cc (get_cygwin_startup_info): Use _CH_* enums.
(child_info_spawn::handle_spawn): Ditto.
(dll_crt0_0): Ditto.
(multiple_cygwin_problem): Ditto.
* exceptions.cc (chExeced): Delete obsolete declaration.
(ctrl_c_handler): Reference set_saw_ctrl_c via new ch_spawn global.
* globals.cc (hExeced): Delete.
* pinfo.cc (pinfo::thisproc): Refer to cygheap as ::cygheap for consistency in
handle naming when -DDEBUGGING.
(pinfo::init): Accommodate case where myself.h is known but h0 is passed in.
(pinfo::pinfo): New constructor for setting up a pinfo passed in by previous
exec'or.
(pinfo::proc_waiter): Don't handle subprocess if we're in the process of
exiting due to an exec of a cygwin process.  Don't close rd_proc_pipe here.
Close it when we actually are finished with the process.  Use new
ch_spawn.signal_myself_exited function to let exec stub know that subprocess
has exited.
(pinfo::wait): Clarify debugging output.
(pinfo::release): Use "close_h" to close all handles to avoid races.
(winpids::add): Assume that elements of the array do not need to be zeroed and
are properly initialized or suffer problems on pinfo::release.  Don't close
hProcess since release does that now.
* pinfo.h: Update comment.
(pinfo_minimal): Move some elements from pinfo here so that child_info_spawn
can use them.
(pinfo): Inherit from pinfo_minimal.
(pinfo::pinfo): Modify to accommodate new pinfo_minimal.
(pinfo::allow_remove): New function.
* sigproc.cc (proc_subproc): Use boolean values for true/false.  Implement
PROC_EXEC_CLEANUP.
(proc_terminate): Set ppid = 1 since the procs list will only be iterated when
the process has not execed.  Don't do any cleanup here since it is now handled
in pinfo::release.
(sigproc_init): Initialize sync_proc_subproc earlier.
(child_info::child_info): Assume that all important fields are properly
initialized and avoid memset().
(child_info_spawn::child_info_spawn): Specifically test for execing and then
set up appropriate fields in the struct.
(child_info_spawn::cleanup): Define new function.
(child_info_spawn::record_children): Specifically test for being execed here.
Fill in pinfo_minimal part of children array.
(child_info_spawn::reattach_children): Use constructor to duplicate information
for previous exec'or.  Add more debugging output.
(remove_proc): Force deletion of thread when exiting due to exec.  Rely on
pinfo::cleanup in release.
* sigproc.h (PROC_EXEC_CLEANUP): New enum.
(PROC_DETACHED_CHILD): Delete.
* spawn.cc (chExeced): Delete.
(child_info_spawn::worker): Rename from spawn_guts.  Use elements of
child_info_spawn throughout rather than ch.whatever.  Use ::cygheap to refer to
global rather than element of child_info.  Use wait_for_myself() rather than
waitpid().  Call child_info_spawn::cleanup on function return.
(spawnve): Reflect movement of spawn_guts functionality into
child_info_spawn::worker.
* syscalls.cc (popen): Ditto.
* winsup.h (spawn_guts): Delete declaration.
2011-11-14 01:29:49 +00:00
Corinna Vinschen 84e9145ca4 * posix.sgml (std-gnu): Add ptsname_r. 2011-11-08 09:24:58 +00:00
Christopher Faylor 926014453f * fhandler.h (__ptsname): New macro.
* dtable.cc (decode_tty): Use __ptsname to generate the slave pty name.
* fhandler_tty.cc (fhandler_pty_master::ptsname_r): Ditto.
* bsdlib.cc: Add needed includes for openpty() changes.
(openpty): Use __ptsname to generate the slave pty name.  Close slave fd when
aslave == NULL.
2011-11-08 06:26:15 +00:00
Christopher Faylor 5d46c490dd * include/cygwin/stdlib.h: Update copyright. 2011-11-08 05:50:18 +00:00
Christopher Faylor 65a6152f18 * cygwin.din (ptsname_r): Export.
* fhandler.cc (fhandler_base::ptsname_r): Define.
* fhandler.h (fhandler_base::ptsname): Delete.
(fhandler_base::ptsname_r): Declare.
(fhandler_pty_master::ptsname_r): Declare.
* fhandler_tty.cc (fhandler_pty_master::ptsname): Delete.
(fhandler_pty_master::ptsname_r): New reentrant function derived from previous
ptsname.
* syscalls.cc (ptsname_r): Implement new function with functionality similar to
Linux.
(ptsname): Use ptsname_r () to fill out buf.
* include/cygwin/stdlib.h (ptsname_r): Declare.
* include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 255 to reflect
export of ptsname_r.
* pinfo.cc (pinfo::wait): Return bool rather than int.
* pinfo.h (info::wait): Ditto.
(pinfo::reattach): Define !defined(_SIGPROC_H) case for consistency.
* sigproc.cc (child_info_spawn::reattach_children): Use correct dwProcessId
rather than pid when duplicating handle.
2011-11-07 20:05:49 +00:00
Corinna Vinschen 78942629ac * fhandler.cc (CHUNK_SIZE): Drop NO_COPY. 2011-11-07 10:06:45 +00:00
Corinna Vinschen 28fa2a72f8 * syscalls.cc (check_dir_not_empty): Check surplus directory entries
by calling NtQueryAttributesFile.  Make STATUS_DIRECTORY_NOT_EMPTY
	return value dependent on its status code.  Add long comment to explain.
	(unlink_nt): Add comment to explain flaw in checking the sharing mode.
	Set status to STATUS_SUCCESS instead of 0.  Add a retry loop to setting
	the delete disposition and trying to move a directory to bin to
	workaround rare cases of lingering, already deleted subdirectory
	entries.  Add long comment to explain.
	(rename): Set status to STATUS_SUCCESS instead of 0.
2011-11-07 10:03:30 +00:00
Christopher Faylor f6ba9446ed * pinfo.cc (status_exit): Recognize STATUS_ILLEGAL_INSTRUCTION.
(child_info::proc_retry): Ditto.
2011-11-05 18:47:39 +00:00
Christopher Faylor 481b6ac0c8 * pinfo.cc (status_exit): Return complete error code. Handle
STATUS_ACCESS_VIOLATION correctly.
(pinfo::set_exit_code): Set self->exitcode directly from status_exit.
2011-11-05 18:29:51 +00:00
Christopher Faylor 26601df44c * pinfo.h (pinfo::reattach): Only set destroy to false when proc_subproc
succeeds.  Return true for success.
* sigproc.cc (child_info_spawn::reattach_children): Try harder to clean up on
error by detecting reattach failures too.
2011-11-04 17:07:21 +00:00
Christopher Faylor 705d704153 * sigproc.cc (child_info_spawn::reattach_children): Clean up handle when can't
open parent process or suffer handle leak.
2011-11-04 16:52:43 +00:00
Christopher Faylor f4bb53c4e0 * sigproc.cc (child_info::sync): Report on exit code in strace output.
(child_info::proc_retry): Don't consider STATUS_ACCESS_VIOLATION as a
restartable event.
2011-11-03 21:44:05 +00:00
Christopher Faylor 277753c80e * sigproc.cc (child_info_spawn::reattach_children): Avoid issuing an error when
we can't duplicate from "parent" since it is probably ok if children of the
previous owner of the pid disappear.
2011-11-03 18:48:27 +00:00
Corinna Vinschen 516fbf67a0 * fhandler.cc (off_current): Define local in fhandler_base::raw_write.
Drop erroneous NO_COPY, add _RDATA to make R/O.
	(off_append): Ditto.
	* globals.cc (_RDATA): Move definition from here...
	* winsup.h: ...to here.
2011-11-03 17:47:33 +00:00
Christopher Faylor 7295e35690 Remove erroneous entry. 2011-10-30 05:21:07 +00:00
Christopher Faylor cd071d1363 * fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take
an options argument for CreateNamedPipe/CreateFile.  Change handle arguments to
expect pointers.
(fhandler_fifo::fifo_state): Delete.
(fhandler_fifo::dummy_client): Ditto.
(fhandler_fifo::open_nonserver): Ditto.
(fhandler_fifo::wait_state): Ditto.
(fhandler_fifo::raw_write): Ditto.
(fhandler_fifo::read_ready): New field.
(fhandler_fifo::write_ready): Ditto.
(fhandler_fifo::wait): Modify argument.
(fhandler_fifo::fifo_name): Add a new argument.
(fhandler_fifo::fixup_after_fork): New function.
* fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of
expunged elements.  Initialize new handles to NULL.
(fhandler_fifo::open_nonserver): Delete.
(fnevent): New macro for creating a named event.
(fnpipe): New macro for creating a unique named pipe name.
(create_pipe): New macro for simplification of named pipe creation.
(fhandler_fifo::fifo_name): Use new argument when creating a shared name.
(fhandler_fifo::open): Rewrite.  Use events to synchronize.
(pure_debug_printf): New macro, active only when DEBUGGING.
(fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied
as a parameter.
(fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect
client-side disconnect.
(fhandler_fifo::raw_write): Delete.
(fhandler_fifo::close): Remove accommodations for expunged fields.  Close event
handles.
(fhandler_fifo::dup): Remove accommodations for expunged fields.  Duplicate
event handles.
(fhandler_fifo::fixup_after_fork): New function.  Perform fixups on event
handles.
(fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields.
Set inheritance for new handle fields.
* miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in
fhandler_pipe::create_selectable.
* tty.cc (tty::not_allocated): Ditto.
* pipe.cc (fhandler_pipe::create): Ditto.
(fhandler_pipe::create_selectable): Accept an extra open_mode argument.  Pass
arguments by reference and allow opening one end of the pipe at a time.
* sys/strace.h (debug_only_printf): Define new macro which calls debug_printf
only when DEBUGGING is defined.
2011-10-30 04:50:36 +00:00
Christopher Faylor 673a691372 * exceptions.cc (sigpacket::process): Avoid a potential deadlock when exiting
due to a signal.
2011-10-28 17:32:38 +00:00
Corinna Vinschen 0c1d8aaaf1 * cygwin.din (getgrouplist): Export.
* grp.cc (get_groups): New static function to run the core functionality
	of initgroups and getgrouplist.
	(initgroups32): Call get_groups and just create supplementary group
	list in cygheap.  Rename name of first argument to "user".  Add an
	assertion to test for a NULL user name.
	(initgroups): Rename name of first argument to "user".
	(getgrouplist): New function.
	* posix.sgml (std-bsd): Add getgrouplist.
	* include/cygwin/grp.h (getgrouplist): Declare.
	* include/cygwin/version.h: Bump API minor number.
2011-10-28 09:26:42 +00:00
Christopher Faylor b79b15e9e3 * child_info.h (cchildren): New struct.
(child_info_spawn::nchildren): Rename from nprocs.
(child_info_spawn::children): Change type to cchildren for more bookkeeping
possibilities.
(child_info_spawn::child_info_spawn): Clear nchildren.
(child_info_spawn::record_children): Declare new function.
(child_info_spawn::reattach_children): Ditto.
* dcrt0.cc (child_info_spawn::handle_spawn): Call reattach_children to gather
list of processes we are potentially waiting for.
* pinfo.h (pinfo::pinfo): Make sure that rd_proc_pipe is always cleared.
(pinfo::reattach): New function.
* sigproc.cc: Move pinfo.h earlier so that it can be used in sigproc.h.
(get_proc_lock): Don't bother with a lock during DLL initialization.
(proc_subproc): Handle PROC_REATTACH_CHILD.
(proc_terminate): Orphan children only when we are not an execed process or
when the pid is about to be occupied by a non-cygwin process.
(child_info_spawn::record_children): Define new function.
(child_info_spawn::reattach_children): Ditto.
* sigproc.h (procstuff): Define PROC_REATTACH_CHILD and renumber other
elements.
* spawn.cc (spawn_guts): Record any to-be-waited-for subprocesses if about to
exec a cygwin process.
* sigproc.cc (sig_send): Fix harmless transposition of fifth and six arguments
to DuplicateHandle().
(child_info::child_info): Ditto.
* globals.cc (hExeced): Make NO_COPY.
2011-10-26 19:42:39 +00:00
Corinna Vinschen be2280986d * hookapi.cc (hook_or_detect_cygwin): Take additional handle
to a file mapping as parameter.  If this handle is not NULL,
	create another file mapping for the IAT.
	* spawn.cc (av::fixup): Only map the first 64K of an image and
	keep the mapping handle to use as argument to hook_or_detect_cygwin.
	* winsup.h (hook_or_detect_cygwin): Add mapping handle as default
	parameter in declaration.
2011-10-25 16:35:58 +00:00
Corinna Vinschen 53e93974c8 * syscalls.cc (unlink_nt): Fix a bug which overwrites the NT status
value in case setting the delete disposition returns with
	STATUS_DIRECTORY_NOT_EMPTY.
2011-10-24 14:02:32 +00:00
Corinna Vinschen b3480fbefb * shared.cc (open_shared): Fix memory reservation of essential shared
memory regions.  Drop delta computations since delta is always 0 in
	non-relocated case.  Add a comment.
2011-10-24 09:19:58 +00:00
Christopher Faylor 31d2bedc58 * fhandler_tty.cc (fhandler_pty_slave::read): Use consistent way for testing
ReadFile return.
* pipe.cc (fhandler_pipe::create_selectable): Open the write side of the pipe
in message-mode to force writing as "chunks".  Explain why.
2011-10-23 19:01:47 +00:00
Christopher Faylor 1f012519e4 * path.cc (path_conv::get_nt_native_path): Avoid dereferencing path when it is
NULL.
2011-10-23 17:19:17 +00:00
Christopher Faylor 6ae28c2263 * dtable.cc (dtable::delete_archetype): Improve debugging output.
(dtable::init_std_file_from_handle): Close console handle early, before
initialization.  Build up openflags for passing to open_setup, just to be safe.
(last_tty_dev): New variable.
(fh_last_tty_dev): New macro.
(fh_alloc): Try again to keep track of previously opened tty, this time by just
saving the device and using that to potentially open an archetype.  Avoid
setting the "/dev/tty" name if the creation of the fhandler failed.
(build_fh_pc): Remove unused second argument.  Reorganize how and where the
name is set.  Set last_tty_dev as appropriate.  Avoid a NULL dereference in a
debug printf.
* dtable.h (build_fh_pc): Reflect removal of second parameter.
* fhandler.cc (fhandler_base::reset): Use new '<<' operator to copy pc since it
preserves any potentially previously set name.
(fhandler_base::set_name): Ditto.
* fhandler.h (fhandler_*::clone): Throughout use ccalloc to allocate new
fhandler, primarily to make sure that pc field is properly zeroed.
(fhandler_termios::last): Eliminate.
(fhandler_termios): Remove setting of last.
(fhandler_base::~fhandler_termios): Ditto.
* fhandler_console.cc (fhandler_console::open): Don't make decisions about
opening close-on-exec handles here since it makes no sense for archetypes.
(fhandler_console::init): Assume that input handle has already been opened.
* fhandler_termios.cc (fhandler_termios::last): Delete.
* path.h (path_conv::eq_worker): New function.  Move bulk of operator = here.
(operator <<): New function.
(operator =): Use eq_worker to perform old functionality.
2011-10-22 16:26:30 +00:00
Corinna Vinschen 22e671336e * fhandler_disk_file.cc (fhandler_disk_file::rmdir): Check invalid
success only on Samba shares.
	* mount.cc (fs_info::update): Drop has_buggy_basic_info flag for
	NcFsd.
	* syscalls.cc (unlink_nt): Fix typo in comment.
2011-10-21 17:43:00 +00:00
Christopher Faylor 2cd3283c8f Check in missing ChangeLog entry. 2011-10-21 12:24:58 +00:00
Corinna Vinschen 69178ca038 * globals.cc (ro_u_ncfsd): New R/O unicode string.
* mount.cc (fs_info::update): Check for "NcFsd" FS.  Set flags and
	change comments accordingly.
	(fs_names): Add entry for NcFsd FS.
	* mount.h (enum fs_info_type): Add ncfsd.
	(class fs_info): Add ncfsd flag and accessor methods.
	* path.h (class path_conv): Add fs_is_ncfsd method.
	* syscalls.cc (unlink_nt): Experimentally try delete-on-close on NcFsd
	in STATUS_CANNOT_DELETE case.
2011-10-21 08:29:19 +00:00
Christopher Faylor b2099ee728 * fhandler.h (fhandler*::copyto): Free path_conv strings first.
* path.h (cfree_and_null): Rename and expand from cfree_maybe.
(path_conv &operator =): Call free_strings rather than freeing strings
directly.
2011-10-20 21:35:59 +00:00
Christopher Faylor 38d732a152 Throughout change TTY_* to PTY_*, tty_* to pty_*, and ttym_* to ptmx_*.
* devices.cc: Regenerate.
* dtable.cc: (fh_alloc): Preserve /dev/tty name when that's what we opened.
(build_fh_pc): Preserve any existing name.
* fhandler.cc (fhandler_base::open_with_arch): Ditto.
* fhandler_tty.cc (fhandler_pty_master::fhandler_pty_master): Force the name to
/dev/ptmx while preserving other pty master device information.
* path.h (cfree_maybe): New macro.
(path_conv::operator =): Free any allocated strings in target.
(path_conv::free_strings): Delete unused function.
* sigproc.cc (proc_terminate): Remove previous accommodation for execed
processes since it didn't have the desired effect.  Change comment to a FIXME.
* spawn.cc (chExeced): Mark NO_COPY.
(exe_suffixes): Ditto.
2011-10-20 14:02:54 +00:00
Corinna Vinschen aa982024d1 * syscalls.cc (try_to_bin): Improve debug output.
(check_dir_not_empty): Take additional path_conv argument.  Improve
	debug output.  Change syscall_printf to debug_printf.
	(unlink_nt): Improve debug output.  Change syscall_printf to
	debug_printf.
	(unlink): Change syscall_printf to debug_printf.

	* cygthread.h: Fix copyright dates.
2011-10-20 10:59:01 +00:00
Corinna Vinschen 53609fd238 * path.cc: Extend two comments. Mention the name RtlpCurDirRef
for reference.
2011-10-18 08:47:08 +00:00
Christopher Faylor ce68abe0b4 * dcrt0.cc (dll_crt0_1): Copy argv before passing to main(). 2011-10-17 18:25:04 +00:00
Christopher Faylor e4257c7366 * sigproc.cc (proc_terminate): Avoid setting ppid to 1 if we're execing. 2011-10-17 15:35:26 +00:00
Christopher Faylor 23771fa1f7 * cygerrno.h (__set_errno): Modify debugging output to make searching strace
logs easier.  Throughout, change /dev/tty* to /dev/pty*.  Throughout, add flags
argument to fhandler_*::dup methods.
* devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN.  Add /dev/ptymN
devices for pty masters.
* devices.cc: Regenerate.
* devices.h (MAX_CONSOLES): Set to max number supported by devices.in.
(fh_devices::FH_PTMX): Rename from FH_PTYM.
(device::operator int): Return by reference.
* dtable.cc (fh_alloc): Take pc as an argument rather than just the device.
This makes debugging easier since more information is available.  Actually
implement handling for already-allocated pty master devices.  Make different
decisions when generating fhandler for not-opened devices.  Add kludge to deal
with opening /dev/tty.
(cnew_no_ctor): New macro.
(build_fh_pc): Make debugging output more verbose.  Use new clone() fhandler
interface to duplicate archetypes.  Reset last term opened.
(dtable::dup_worker): Use Use new clone() fhandler interface to duplicate
archetypes.  Pass flags to child dup handler.
(dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr.
* fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce
functionality and sense of copy direction.
(fhandler_base::open_with_arch): Use published interface to query io_handle().
Use new copyto() fhandler method to copy from/to found archetype.
* fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_*
(void *) methods.
(fhandler_base::reset): Rename from operator =().
(fhandler_termios::is_dev_tty): Delete.
(fhandler_termios): change "protected" region to "private".
(fhandler_termios::is_dev_tty): Delete.
(fhandler_termios): Rearrange protected/public.
(fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened".
(fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened.
(ioctl): Rename from ioctl_termios.  Take a void * argument.  Reflect argument
change in pinfo::set_ctty.
(fhandler_console::dup): Declare new function.  Set ctty here if appropriate.
(fhandler_pty_master::from_master): Privatize.
(fhandler_pty_master::to_master): Ditto.
(fhandler_pty_master::dwProcessId): Ditto.
(fhandler_pty_master::fhandler_pty_master): Add an `int' argument.
(fhandler_pty_master::open_setup): Declare new function.
(fhandler_pty_master::~fhandler_pty_master): Declare new method.
(fhandler_nodevice): Remove commented out function declaration.
* fhandler_console.cc: Use get_ttyp() instead of tc() throughout.
(fhandler_console::dup): Define new function to set controlling ctty on dup, as
appropriate.
(fhandler_console::ioctl): Reflect ioctl_termios name change.
(fhandler_console::setup): Rename from get_tty_stuff.
(fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty.
(fhandler_console::fhandler_console): Set _tc here.
* fhandler_termios.cc (handler_termios::ioctl): Rename.  Take a void * arg like
other ioctl functions.
* fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to
potentially reset the controlling terminal.
(fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios.
(fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument.  Call setup()
here so that we will know the unit number of this fhandler as soon as possible.
Set the unit as appropriate.
(handler_pty_master::open): Move most stuff to constructor and open_setup.
(handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty.
(handler_pty_master::open_setup): Define new function.
(fhandler_pty_master::cleanup): Clear handles as a flag that the destructor
does not have to do "close" operations.
(fhandler_pty_master::close): Ditto.
(fhandler_pty_master::~fhandler_pty_master): Define new method.
(fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios.
(fhandler_pty_master::setup): Allocate tty here.  Rely on handles being
returned from allocated test rather than opening them here.  Avoid setting
_need_nl here since it is already zeroed in the constructor.  Set up device
information with DEV_TTYM_MAJOR.
* path.h (path_conv &operator =): Take a const argument.
(path_conv::dup): Ditto.
(pathconv_arg::PC_OPEN): New enum.
(pathconv_arg::PC_CTTY): Ditto.
(path_types::PATH_CTTY): Ditto.
(path_types::PATH_OPEN): Ditto.
(path_conv::isopen): New method.
(path_conv::isctty_capable): Ditto.
* path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate.
* pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle.
* syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on
non-std* handles.
* tty.cc (tty_list::allocate): Pass out handles for allocated tty.  use
`not_allocated' to find unallocated ttys.  Avoid keeping the lock since the
allocation of the tty should be sufficient to prevent multiple access.
(tty::not_allocated): Clarify comment.  Rename.  Return handles when an unused
tty is found.  Simply test for existing tty.
(tty::exists): Rewrite to use `not_allocated'.
* tty.h (NTTYS): Reset down to actual number supported by devices.in.
(tty::not_allocated): Declare new function.
(tty_list::allocate): Pass out read/write tty handles.  Zero them when not
found.
* fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX.
* pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in.
* pinfo.cc (pinfo::set_ctty): Ditto.  Just use tc() built into the passed-in
fhandler_termios pointer.  Return true if ctty is assigned.
* syscalls.cc (open): Call build_fh_pc with PC_OPEN flag.  Set PC_CTTY if
appropriate.
(stat_worker): Remove is_dev_tty () stuff.
2011-10-15 22:37:30 +00:00
Corinna Vinschen a9cc13a8e0 * fhandler_process.cc (dos_drive_mappings::fixup_if_match): Convert
native NT network paths into DOS UNC paths.
2011-10-15 19:13:57 +00:00
Corinna Vinschen c52fd6cd47 * sec_auth.cc (get_token_group_sidlist): Add CONSOLE LOGON SID on
systems supporting it.  Never add SERVICE SID but keep code in for
	future reference.  Explain why.
	(get_priv_list): Add cygpsid pointer parameter.  Point it to the
	mandatory integrity SID which matches account and privileges.
	(create_token): Fetch mandatory integrity SID from call to
	get_priv_list.
	(lsaauth): Call get_priv_list with additional NULL pointer.  Change
	comment accordingly.
	* sec_helper.cc (well_known_console_logon_sid): New static SID.
	(cygpriv): Change to structure containing extra flag to store info
	about required integrity level.
	(privilege_luid): Accommodate changes to cygpriv.  Return integrity
	level in new high_integrity parameter.
	(privilege_name): Accommodate changes to cygpriv.
	(set_privilege): Drop trailing \n from debug output.
	(set_cygwin_privileges): Don't set SE_CREATE_GLOBAL_PRIVILEGE anymore
	since it's just not needed, but keep code in for future reference.
	Change comment accordingly.
	* security.h (well_known_console_logon_sid): Declare.
	(privilege_luid): Align declaration to above change.
	* wincap.h (wincaps::has_console_logon_sid): New element.
	* wincap.cc: Implement above element throughout.
2011-10-15 16:31:57 +00:00
Corinna Vinschen 76173acf28 * path.cc (find_fast_cwd_pointer): Allow 'push crit-sect-addr' instead
of 'mov edi, crit-sect-addr; push edi' and set rcall accordingly.
2011-10-13 16:47:32 +00:00
Corinna Vinschen 40187f9007 * path.cc (copy_cwd_str): Move up in file to be accessible from
class fcwd_access_t.
	(class fcwd_access_t): New class to consolidate and hide the details
	of the various FAST_CWD implementations.  Add implementation for
	Windows 8 Developer Preview.
	(fast_cwd_version): Make static private member of fcwd_access_t.
	(fast_cwd_ptr): Change base type to fcwd_access_t.
	(find_fast_cwd_pointer): Return fcwd_access_t**.
	(find_fast_cwd): Ditto.  Rip out all FAST_CWD implementations and use
	fcwd_access_t methods instead.
	(cwdstuff::override_win32_cwd): Ditto.
2011-10-13 15:32:10 +00:00
Corinna Vinschen 5de3a1c10f * fhandler_console.cc (fhandler_console::cursor_set): Disable forcing
y to the current winBottom position.  Explain why.
2011-10-12 14:19:20 +00:00
Christopher Faylor 4add6f8db1 * cygwin.din: Remove some _tc* exports. Add tcgetsid().
* dtable.cc (fh_alloc): Revert ill-advised setting of major/minor.  Use new
is_dev_tty to remember that this device was opened as /dev/tty.
* fhandler.cc (fhandler_base::fstat): Remove leftover debugging statement.
(fhandler_base::tcgetsid): New function.
* fhandler.h ((fhandler_base::tcgetsid): Declare new function.
(fhandler_base::is_dev_tty): Ditto.
(fhandler_termios::opened_as_dev_tty): Declare new field.
(fhandler_termios::is_dev_tty): Declare new function.
(fhandler_termios::tcgetsid): Ditto.
(fhandler_pty_common::use_archetype): Move here from subclass.
(fhandler_pty_slave::use_archetype): Move up.
(fhandler_pty_master::use_archetype): Ditto.
* fhandler_console.cc (fhandler_console::ioctl): Rename second argument from
`buf' to `arg' for consistency.  Call ioctl_termios for common fhandler_termios
ioctl handling.
* fhandler_tty.cc (fhandler_pty_slave::ioctl): Call ioctl_termios for common
fhandler_termios ioctl handling.
(fhandler_pty_master::ioctl): Ditto.
* fhandler_termios.cc (fhandler_termios::tcgetsid): Implement new function.
(fhandler_termios::ioctl_termios): Ditto.  Implements TIOCSCTTY handling.
* syscalls.cc (stat_worker): Set /dev/tty device info when appropriate.
* termios.cc (tcgetpgrp): Avoid extraneous "isatty" check.
(tcgetsid): Implement new function.
* include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 253.
* include/sys/termios.h (TIOCSCTTY): Define.
2011-10-11 23:20:38 +00:00
Christopher Faylor 1e5bcae135 * dtable.cc (fh_alloc): Don't parse /dev/tty if ctty is < 0. Reset major/minor
from the specific tty to those for /dev/tty.
2011-10-11 12:39:31 +00:00
Christopher Faylor be96a30c43 * syscalls.cc (open): Add temporary kludge to avoid assigning the controlling
tty on open unless the open is for stdin/stdout/stderr.
* tty.cc (tty_list::connect): Set ENXIO when can't find a tty.
2011-10-10 22:01:06 +00:00
Corinna Vinschen 4c34aaba55 * fhandler.h (fhandler_process::closedir): Declare.
* fhandler_process.cc (fhandler_process::closedir): New function to
	avoid a SEGV in fhandler_proc::closedir.
2011-10-10 18:59:56 +00:00
Christopher Faylor 336e8ee685 * fhandler_tty.cc (fhandler_pty_slave::open): Clarify debugging output.
(fhandler_pty_slave::open): Change ENOENT to ENXIO when can't open a tty.
2011-10-10 04:05:29 +00:00
Christopher Faylor 3d1dd0789e * fhandler.h (fhandler_console::tc_getpgid): New function.
* spawn.cc (spawn_guts): Add logic to put pure-windows processes "in the
background" when they are started that way.
2011-10-07 13:52:20 +00:00
Corinna Vinschen c53c656b1c * include/sys/cygwin.h (cygwin_getinfo_types): Define values
additionally as preprocessor symbols.
2011-10-07 13:49:17 +00:00
Corinna Vinschen 7bbfea993a Fix copyright. 2011-10-07 08:14:25 +00:00
Corinna Vinschen 852908e82d * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Send __SIGSETPGRP
pseudo signal to process group instead of just calling
	init_console_handler.
	* sigproc.cc (wait_sig): Call init_console_handler here on __SIGSETPGRP
	signal.
	* sigproc.h (__SIGSETPGRP): Define.
2011-10-06 19:47:45 +00:00
Christian Franke efe716bb8e 2011-10-06 Christian Franke <franke@computer.org>
* include/cygwin/wait.h: Use new __wait_status_to_int()
	macro to access status value in W*() status checks.
	Fix status description.
	* include/sys/wait.h: Allow `int' and `union wait' as
	wait status parameter.  Change __wait_status_to_int()
	macro and wait () prototypes accordingly.  Add inline
	functions for C++.  Remove extra `;'.
2011-10-06 16:02:37 +00:00
Corinna Vinschen 8dfce03bfa * external.cc (create_winenv): Rename from sync_winenv. Take
environment pointer as parameter and return pointer to corresponding
	win32 environment block if != NULL.  Otherwise just sync as before.
	(cygwin_internal): Add CW_CVT_ENV_TO_WINENV case.
	* include/cygwin/version.h: Bump API minor number.
	* include/sys/cygwin.h (cygwin_getinfo_types): Add CW_CVT_ENV_TO_WINENV.
2011-10-05 12:27:37 +00:00
Corinna Vinschen a06c3bf336 * net.cc (socketpair): Bind first socket to loopback only as well. 2011-10-05 06:18:16 +00:00
Christopher Faylor 36b6320736 * tty.cc (grantpt): Check for valid fd.
(unlockpt): Ditto.
2011-09-21 04:33:57 +00:00
Corinna Vinschen 35e8bb2b7e * net.cc (cygwin_getsockopt): Drop erroneous double conversion of error
code returned by SOL_SOCKET/SO_ERROR.  Fix error handling.
2011-09-02 09:52:08 +00:00
Corinna Vinschen d94522a76a * lc_msg.h: Regenerate. 2011-09-01 19:19:29 +00:00
Corinna Vinschen e2d88014ac * dlfcn.cc (gfpod_helper): Helper function to search DLL using
a given DLL name.  Change default search path to allow /usr/bin.
	(get_full_path_of_dll): Find DLLs even if the caller used a ".so"
	suffix or a "lib" prefix for the DLL.
2011-09-01 08:17:07 +00:00
Corinna Vinschen 52a5f8cc1a * flock.cc (inode_t::unlock_and_remove_if_unused): Rename from
unlock_and_remove.
2011-08-31 16:35:19 +00:00
Corinna Vinschen 2e560a092c * flock.cc (LOCK_OBJ_NAME_LEN): Change to accommodate extra lf_ver
field.
	(class lockf_t): Add lf_ver field.
	(lockf_t::lockf_t): Initialize lf_ver to 0.
	(class inode_t): Change i_wait to i_cnt.  Change comment to explain
	change in usage.
	(inode_t:use): Rename from wait.  Make private.
	(inode_t::unuse): Rename from unwait.  Make private.
	(inode_t::inuse): Rename from waiting.  Make private.
	(inode_t::notused): New public method to set use count to 0.
	(inode_t::unlock_and_remove): New method to unlock node and to delete
	it if it's unused in current process.
	(fhandler_base::del_my_locks): Drop global list lock.  Drop variable
	no_locks_left.  Simpify unlocking and removing node by just calling
	unlock_and_remove.
	(fixup_lockf_after_exec): Call notused method for each node.
	(inode_t::get): Call use method.  Lock node only if outside of list
	lock.
	(inode_t::get_all_locks_list): Accommodate additional lf_ver field
	when creating lockf_t structure from object name.
	(lockf_t::create_lock_obj_attr): Accommodate additional lf_ver field
	when creating object name from lockf_t structure.  Handle
	STATUS_OBJECT_NAME_COLLISION gracefully in F_POSIX case as well.
	Change comment accordingly.  Increment lf_ver field rather than high
	byte of lf_wid field.  Simplify comment.
	(fhandler_disk_file::lock): Always call unlock_and_remove rather than
	just UNLOCK on node.
	(lf_setlock): Move ret definition where it's used.  Drop unneeded
	tests for obj being not NULL.  Only check for deadlock condition if the
	lock we're trying to establish is a POSIX lock.  Revamp object
	collecting and wait code to cover all cases.  Don't return with EDEADLK
	if blocking process can't be opened for synchronization in F_POSIX case,
	rather just wait like in F_FLOCK case.  Change system_printf to
	debug_printf in that case.  Only run WaitForMultipleObjects with high
	priority.  Close obj and process handles prior to locking node.
2011-08-29 13:50:25 +00:00
Corinna Vinschen f4ec874328 * fhandler.cc (fhandler_base::open): Fix typo in comment.
(fhandler_base::close): Move call to del_my_locks from here...
	* fhandler_disk_file.cc (fhandler_disk_file::open): ...to here.
	* flock.cc (struct lockfattr_t): New type.
	(lockf_t::close_lock_obj): New method, use throughout.
	(lockf_t::create_lock_obj_attr): New method.
	(lockf_t::create_lock_obj): Use create_lock_obj_attr method.  Handle
	STATUS_OBJECT_NAME_COLLISION in F_FLOCK case gracefully.  Add lengthy
	comments to explain why and how.
	(lockf_t::open_lock_obj): Use create_lock_obj_attr method.
	(lockf_t::del_lock_obj): Call NtSetEvent rather than SetEvent for
	symmetry.
	(fhandler_disk_file::lock): Define n only where it's used.  Call
	need_fork_fixup only if call was successful.  Handle EINTR and
	ECANCELED return values from lf_setlock.
	(lf_setlock): Drop WAIT_UNLOCKED and WAIT_PROC_EXITED.  Don't wait
	for event object handle count to become <= 1 in F_LOCK case.
	Simplify WFMO return value handling.  Don't handle signal and cancel
	events here; just return with appropriate error code instead.
	(lf_getblock): Ignore locks for which the handle can't be opened.
	Use IsEventSignalled.
	* ntdll.h (STATUS_INVALID_INFO_CLASS): Undef if defined elsewhere to
	make sure the definition is casted to NTSTATUS.
	(STATUS_INVALID_HANDLE): Define and ditto.
	(STATUS_OBJECT_NAME_COLLISION): Define.
	(NtSetEvent): Declare.
2011-08-27 20:01:29 +00:00
Christopher Faylor 2691168e98 * cygthread.cc (cygthread::simplestub): Notify that the thread has detached
also in freerange thread case.
2011-08-25 19:37:39 +00:00
Corinna Vinschen 603ef545bd * fhandler.cc (fhandler_base::open): Never open files with
FILE_OVERWITE/FILE_OVERWRITE_IF.  Set file size to 0 explicitely if
	regular, existing file has been opened for writing with O_TRUNC flag
	set.  Explain why.
2011-08-25 13:35:43 +00:00
Corinna Vinschen 929a140824 * thread.cc (pthread::pthread): Drop setting parent_tls. Call
sigprocmask to copy parent thread signal mask into new parent_sigmask
	member.
	(pthread::thread_init_wrapper): Copy _my_tls.sigmask from new
	parent_sigmask member.
	* thread.h (class pthread): Drop parent_tls.  Add parent_sigmask.
2011-08-24 15:18:17 +00:00
Christopher Faylor 8323a37d5d * thread.cc (pthread::exit): Create dummy tls structure to hold _main_tls
contents if we've asked _main_tls to exit.
2011-08-24 14:23:38 +00:00
Corinna Vinschen 58ef30a4e7 * poll.cc (poll): Don't return prematurely if invalid fds have been
encountered.  Enforce timeout set to 0 in case of invalid fds.  Take
	number of invalid fds into account when returning.
2011-08-23 14:05:04 +00:00
Corinna Vinschen 247caa48ea * fhandler_socket.cc (fhandler_socket::send_internal): Fix setting
nosignal flag.  Convert ECONNABORTED on connection-oriented socket
	to EPIPE, too.
2011-08-23 13:07:24 +00:00
Christopher Faylor 059f809e4b * dtable.cc (conv_start_chars): Remove unneeded section attribute. 2011-08-21 18:45:07 +00:00
Yaakov Selkowitz 0cd08cee4b * include/paths.h (_PATH_MAILDIR): Define.
(_PATH_SHELLS): Define.
2011-08-21 03:22:30 +00:00
Corinna Vinschen f71c1cdb55 * fhandler_process.cc (format_process_maps): Define page protection
shortcuts RO, X, and WC.  Use in creating access flag string.  Don't
	set type flag to 's' for copy-on-write pages, as on Linux.
2011-08-20 18:55:45 +00:00
Yaakov Selkowitz 07797cc0d8 * devices.h (fh_devices): Define DEV_MISC_MAJOR, DEV_MEM_MAJOR,
DEV_SOUND_MAJOR.  Use throughout.
* fhandler_proc.cc (proc_tab): Add /proc/devices and /proc/misc
virtual files.
(format_proc_devices): New function.
(format_proc_misc): New function.
2011-08-19 20:05:15 +00:00
Christopher Faylor c8a66289e4 * dtable.cc: Mark some const variables as static.
* environ.cc (conv_start_chars): Move to shared cygwin region and initialize at
compile time.
(match_first_char): New generic function for querying conv_start_chars.
(posify_maybe): Rename from posify.
(environ_init): Remove conv_envvars initialization.  Don't check
conv_start_chars, just allow posify_maybe to make the decision.
* fhandler_console.cc (__vt100_conv): Fix formatting.  Mark as const.
2011-08-19 18:19:22 +00:00
Corinna Vinschen aeeaae457b * fhandler_console.cc (fhandler_console::read): Recognize backspace key
using the device independent key code, rather than the device dependent
	scan code.
2011-08-19 13:10:01 +00:00
Christopher Faylor 6072b95eeb * dcrt0.cc (dll_crt0_0): Remove unneeded __stdcall decoration.
* init.cc: Reflect change to dll_crt0_0 in declaration.
2011-08-18 15:59:16 +00:00
Corinna Vinschen 8f19b4b64f * dtable.cc (dtable::get_debugger_info): Add missing braces.
(dtable::stdio_init): Fix incorrect negation of not_open(2) condition.
2011-08-18 09:16:50 +00:00
Pierre Humblet 927761a425 2011-08-16 Pierre Humblet <Pierre.Humblet@ieee.org>
* net.cc (gethostby_helper): Remove DEBUGGING code from and
        streamline the second pass.
2011-08-16 23:32:18 +00:00
Corinna Vinschen 833db5481f * dlfcn.cc (dlopen): Reimplement RTLD_NODELETE for Windows 2000 using
internal datastructures.  Explain the code.
	* ntdll.h (struct _LDR_DATA_TABLE_ENTRY): Define.
	(struct _PEB_LDR_DATA): Define.
	(struct _PEB): Change PVOID LoaderData to PPEB_LDR_DATA Ldr.

	* fhandler_process.cc (format_process_maps): Call NtQueryVirtualMemory
	with valid return length pointer.  Explain why.
2011-08-16 20:08:34 +00:00
Corinna Vinschen c429beb296 * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-08-16 14:48:38 +00:00
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