Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2012-08-17whitespace cleanupChristopher Faylor
2012-06-18Add '#include "cygwait.h"' throughout, where appropriate.Christopher Faylor
* DevNotes: Add entry cgf-000012. * Makefile.in (DLL_OFILES): Add cygwait.o. * sigproc.h: Remove cygwait definitions. * cygwait.h: New file. Define/declare Cygwin waitfor functions. * cygwait.cc: Ditto. * exceptions.cc: Include cygwait.h. (handle_sigsuspend): Accommodate change in cancelable_wait arguments. (sigpacket::process): Display thread tls in debugging output. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use symbolic names for signal and cancel return. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_dev_dsp::Audio_out::waitforspace): Ditto. fhandler_dev_dsp::Audio_in::waitfordata): Ditto. * fhandler_fifo.cc (fhandler_fifo::wait): Ditto. * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. * fhandler_tty.cc (fhandler_pty_slave::read): Ditto. * select.cc (cygwin_select): Ditto. * wait.cc (wait4): Ditto. * thread.cc (cancelable_wait): Move definition to cygwait.h. (pthread_cond::wait): Accommodate change in cancelable_wait arguments. (pthread_mutex::lock): Ditto. (pthread_spinlock::lock): Ditto. (pthread::join): Ditto. (pthread::thread_init_wrapper): Display tls in debugging output. (semaphore::_timedwait): Ditto. * thread.h (cw_sig_wait): Move to cygwait.h. (cw_cancel_action): Delete. (cancelable_wait): Move declaration to cygwait.h.
2012-03-13Christopher Faylor <me.cygwin2012@cgf.cx>Christopher Faylor
* fhandler.h (wait_return): Add overlapped_nullread. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Detect zero-byte read as a special case. (fhandler_base_overlapped::raw_read): Keep looping when zero-byte read detected without EOF. (fhandler_base_overlapped::raw_write): Quiet gcc warning by adding overlapped_nullread to switch statement even though it will never actually be hit.
2012-03-08 * Throughout, replace usage of w32api's min with MIN from sys/param.h.Corinna Vinschen
2012-02-28tcgetsid: fix return typeEric Blake
* include/sys/termios.h (tcgetsid): Fix return type. * termios.cc (tcgetsid): Likewise. * fhandler_termios.cc (fhandler_termios::tcgetsid): Likewise. * fhandler.h (fhandler_base): Likewise. * fhandler.cc (fhandler_base::tcgetsid): Likewise.
2012-02-01* fhandler.cc (fhandler_base_overlapped::has_ongoing_io): Don't blockChristopher Faylor
GetOverlappedResult since previous IsEventSignalled will have reset the handle. * select.cc (cygwin_select): Remove space before parentheses in syscall debugging output. (pipe_data_available): Streamline if block.
2012-02-01* syscalls.cc (dup3): Fix debug typo.Christopher Faylor
* fhandler.cc (flush_async_io): Assume only called for writer. Call GetOverlappedResult directly rather than kluding call to has_ongoing_io. (fhandler_base_overlapped::close): Only start flush thread when closing write handle. Only cancel I/O when reading.
2012-01-22* cygheap.h (cygheap_fdget::~cygheap_fdget): Simplify now that refcnt reportsChristopher Faylor
reference count changes itself. * fhandler.cc (fhandler_base::reset): Set _refcnt to 0. * fhandler.h (fhandler_base::refcnt): Report refcnt when debugging. * select.cc (cygwin_select): Set return_on_signal to indicate when select should be interrupted. (select_stuff::wait): Keep looping unless return_on_signal is set. * select.h (select_stuff::return_on_signal): New variable. (select_stuff::select_stuff): Zero return_on_signal.
2011-12-21* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use correct value inChristopher Faylor
switch statement.
2011-12-18* fhandler.cc (fhandler_base::close): Move setting isclosed() from here toChristopher Faylor
closed(). (fhandler_base_overlapped::close): Correct comment. (fhandler_base_overlapped::destroy_overlapped): Signal overlapped event before closing it to potentially wake up a waiting thread. (fhandler_base_overlapped::wait_overlapped): Expand setting of err when closed to encompass non-signal event. Test for a cancel event before making nonblocking decisions. * syscalls.cc (close): Set closed flag here so that any concurrently executing functions will be notified ASAP.
2011-12-17* exceptions.cc (set_signal_mask): Remove useless debugging output.Christopher Faylor
* fhandler.cc (fhandler_base::write): Ditto. (fhandler_base_overlapped::close): Cancel any ongoing I/O before closing. * syscalls.cc (write): Default to always reporting all writes in strace output via syscall_printf. * wait.cc (wait4): Fix debugging output. Use standard syscall leaver output.
2011-12-17Implement fhandler reference counting.Christopher Faylor
* cygheap.h (cygheap_fdmanip::release): Make virtual. (cygheap_fdnew::~cygheap_fdnew): New destructor increments reference count when fd has been allocated. (cygheap_fdget::fh): New (old?) field. (cygheap_fdget::cygheap_fdget): Increment reference count when we've found an active fd. Set fh appropriately. (cygheap_fdget::~cygheap_fdget): Decrement reference count when appropriate. Delete fh if reference count goes to zero. (cygheap_fdget::release): New function. Do more bookkeping on release. * dtable.cc (dtable::release): Change from void to boolean return. Only delete the fhandler when its reference count is <= 0 (this should be a fairly unusual case). Return true if fhandler has been deleted. (cygwin_attach_handle_to_fd): Increment reference count when fh is assigned. (dtable::init_std_file_from_handle): Ditto. * dtable.h (dtable::release): Change return to boolean. * fhandler.cc (fhandler_base::fhandler_base): Set new isclosed flag to false. Set _refcnt to zero. (fhandler_base::close): Simplify paranoid debugging output. Set new isclosed() flag. (fhandler_base_overlapped::wait_overlapped): Use isclosed() flag to avoid querying the exception handle. * fhandler.h (fhandler_base::_refcnt): New field. (fhandler_base::refcnt): New function. (fhandler_base::isclosed): Implement. (fhandler_base::fhandler_base): Set isclosed to false. * syscalls.cc: Remove space after function before parentheses for several strace printfs. (dup): Add standard strace "leaver" code. (dup2): Ditto. (dup3): Ditto. (remove): Ditto. (getpid): Ditto. (getppid): Ditto. (lseek64): Fix strace debugging to correctly use %R. * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Avoid sending signals to other processes if we're debugging since it can cause a deadlock with the calling debugger. * exceptions.cc (_cygtls::call_signal_handler): Add debugging-only strace output.
2011-12-16* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Fix unresolvedChristopher Faylor
access of wores in successful situations.
2011-12-16* exceptions.cc (_cygtls::call_signal_handler): Fix debugging to not go toChristopher Faylor
console. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Add temporary kludge to work around problem of make closing a handler while it is being read. * gendef (sigdelayed): Don't call a function if sig has been cleared. * sigproc.h (cygwait): Simplify slightly.
2011-12-13* cygthread.h (cygthread::name): Very minor formatting tweak.Christopher Faylor
* exceptions.cc (_cygtls::call_signal_handler): Add paranoid debugging output. * sigproc.h (cygwait): Call signal handler when signal is detected and loop as appropriate. * fhandler.h (fhandler_base_overlapped::wait_return): Remove overlapped_signal. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Remove restartable signal accommodations in light of cygwait improvements. (fhandler_base_overlapped::raw_read): Remove now-obsolete signal loop behavior. (fhandler_base_overlapped::raw_write): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. (fhandler_serial::raw_write): Ditto. * fhandler_tty.cc (fhandler_pty_slave::read): Ditto. * ioctl.cc (ioctl): Add standard syscall introducer and leaver debug output.
2011-12-09Rename cygWFMO to cygwait throughout and use the magic of polymorphism to "waitChristopher Faylor
for stuff". * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use simplified arg form of cygwait. * fhandler_console.cc (fhandler_console::read): Ditto. * fhandler_audio.cc (fhandler_dev_dsp::Audio_out::waitforspac): Ditto. (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. * select.cc (cygwin_select): Ditto. * sigproc.h (cygwait): Rename from cygWFMO. Define two argument and single argument forms of this function. * fhandler_tty.cc (fhandler_pty_slave::open): Use method to query if tty is open. (fhandler_pty_slave::read): Send SIGHUP when master is detected as closed. (fhandler_pty_common::close): Close input_available_event in callers since master may need to signal it first. (fhandler_pty_master::close): Lie and set input_available_event when closing, then close input_available_event. (fhandler_pty_slave::close): Close input_available_event explicitly here. * tty.h (tty::is_master_closed): Declare new method.
2011-12-04* exceptions.cc (exception::handle): Drop abbreviation for "exception" since IChristopher Faylor
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-04Throughout, remove extra space after function name from debugging output.Christopher Faylor
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-04 * fhandler.cc (fhandler_base::open): Fix comment a bit more.Corinna Vinschen
2011-12-03 * fhandler.cc (fhandler_base::open): Fix typos in comment.Corinna Vinschen
2011-11-29* sigproc.cc (remove_proc): Don't terminate the currently executing thread.Christopher Faylor
2011-11-08* cygwin.din (ptsname_r): Export.Christopher Faylor
* 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 * fhandler.cc (CHUNK_SIZE): Drop NO_COPY.Corinna Vinschen
2011-11-03 * fhandler.cc (off_current): Define local in fhandler_base::raw_write.Corinna Vinschen
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-10-30* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, takeChristopher Faylor
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-22* dtable.cc (dtable::delete_archetype): Improve debugging output.Christopher Faylor
(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-20Throughout change TTY_* to PTY_*, tty_* to pty_*, and ttym_* to ptmx_*.Christopher Faylor
* 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-16* cygerrno.h (__set_errno): Modify debugging output to make searching straceChristopher Faylor
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-12* cygwin.din: Remove some _tc* exports. Add tcgetsid().Christopher Faylor
* 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-08-28 * fhandler.cc (fhandler_base::open): Fix typo in comment.Corinna Vinschen
(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-25 * fhandler.cc (fhandler_base::open): Never open files withCorinna Vinschen
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-07-22Corinna Vinschen <corinna@vinschen.de>Christopher Faylor
* 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-05 * fhandler.cc (fhandler_base::open): Never create files with WRITE_DACCorinna Vinschen
access. Explain why. * fhandler_disk_file.cc (fhandler_base::fstat_helper): Improve debug output.
2011-07-05 * fhandler.cc (fhandler_base::open): Don't open file with WRITE_DACCorinna Vinschen
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-04* fhandler.cc (fhandler_base::open_with_arch): Call close_on_exec last to avoidChristopher Faylor
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-01 * fhandler.cc (fhandler_base::open): Move NFS-specific code into theCorinna Vinschen
code block handling FH_FS stuff.
2011-06-17 * fhandler.cc (fhandler_base::open): Drop local create_options variable.Corinna Vinschen
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-04* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Only raise SIGPIPEChristopher Faylor
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-05-31* dtable.cc (dtable::select_write): Add missing argument to debug_printf.Christopher Faylor
* 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-30* dll_init.cc (dll_list::append): Eliminate increment of unused tot variable.Christopher Faylor
* 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-29* fhandler.cc (fhandler_overlapped::wait_overlapped): Make sure that I/O isChristopher Faylor
cancelled on signal.
2011-05-28* fhandler.cc (handler_base_overlapped::wait_overlapped): Rework to attempt toChristopher Faylor
properly set errno and bytes read for non-blocking case. Change to just rely on res to indicate error conditions.
2011-05-28* autoload.cc: Call _api_fatal in asm.Christopher Faylor
* 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-07* fhandler.cc (fhandler_base::dup): Avoid duping a handle when an fhandler hasChristopher Faylor
an archetype. * fhandler_console.cc (fhandler_console::invisible_console): Move to the top. (fhandler_console::set_close_on_exec): Don't set close-on-exec on handle since it's an archetype and you don't know how many things could be using it.
2011-05-06* cygheap.cc (cygheap::close_ctty): Close ctty via close_with_arch().Christopher Faylor
* debug.cc (close_handle): Call debugger on failure. * devices.in (device::tty_to_real_device): Delete. * devices.h (device::tty_to_real_device): Ditto. * devices.cc: Regenerate. * dtable.cc: Delete old ifdef'ed vfork code. (dtable::release): Don't handle archetype here. (dtable::init_std_file_from_handle): Consolidate console tests. Generate major/minor for tty ASAP. Fix incorrect setting of DEV_TTYS* for serial. (fh_alloc): New function derived from build_fh_pc. Pass current tty when building tty. (build_pc_pc): Use fh_alloc to create. Set name from fh->dev if appropriate. Generate an archetype or point to one here. (dtable::dup_worker): Deal with archetypes. Rely on = operator copying whole class rather than just fhandler_base. (dtable::fixup_after_exec): Call close_with_arch to handle closing of fhandlers with archetypes. * fhandler.cc (fhandler_base::operator =): Call memcpy with fhandler's size() rather than sizeof fhandler_base. (fhandler_base::open_with_arch): New function. Handles opening of fhandler's with archetypes, dealing with usecounts, etc. (fhandler_base::close_with_arch): Ditto for close. * fhandler.h: Many changes for archetypes. (fhandler_base::set_name): Set both normalized path and regular path. (fhandler_base::open_with_arch): New function. (fhandler_base::open_setup): Ditto. (fhandler_base::use_archetype): Ditto. (fhandler_base::_archetype_usecount): Ditto. (fhandler_*::size): Ditto. (fhandler_dev_tape::open): Remove virtual decoration. (fhandler_console::use_archetype): New function. Return true. (fhandler_console::open_setup): New function. (fhandler_console::dup): Delete. (fhandler_tty_slave::fhandler_tty_slave): Redeclare to take an argument. (fhandler_tty_slave::use_archetype): New function. Return true. (fhandler_tty_slave::cleanup): New function. (fhandler_pty_master::use_archetype): New function. Return true. (fhandler_pty_master::cleanup): New function. (fhandler_pty_master::is_tty_master): New function. Return false. (fhandler_tty_master::is_tty_master): New function. Return true. (fhandler_dev_dsp::fhandler_dev_dsp): New function. Return true. (report_tty_counts): Only report on archetype's usecount if there is one. * fhandler_console.cc (fhandler_console::get_tty_stuff): Remove handling of setsid, set_ctty, set_flags, and manage_console_count. (fhandler_console::open_setup): New function. Implement functionality removed from get_tty_stuff. (fhandler_console::dup): Delete. (fhandler_console::output_tcsetattr): Set errno on error. (fhandler_console::fhandler_console): Set device early. (fhandler_console::init): Use open_with_arch to open console handles. (fhandler_console::fixup_after_fork_exec): Nuke most of the stuff for dealing with console handles. * fhandler_dsp.cc (fhandler_dev_dsp::open): Remove archetype handling. (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. (fhandler_dev_dsp::close): Ditto. (fhandler_dev_dsp::dup): Ditto. (fhandler_dev_dsp::ioctl): Ditto. (fhandler_dev_dsp::fixup_after_fork): Ditto. (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Add a little more debugging. (fhandler_tty_common::__release_output_mutex): Ditto. (fhandler_pty_master::process_slave_output): Ditto. Don't do signal handling or pthread_cancel handling in the tty master thread. (process_output): Minor reorg. (fhandler_tty_slave::fhandler_tty_slave): Set device based on new ntty argument. (fhandler_tty_slave::open): Remove archetype handling. Move some processing into open_setup(). (fhandler_tty_slave::open_setup): New function. (fhandler_tty_slave::cleanup): New function. (fhandler_tty_slave::close): Remove archetype handling. Move some processing into cleanup(). (fhandler_tty_slave::init): Rename argument from f to h. Open device using open_with_arch(). Remove archetype handling. (fhandler_pty_master::dup): Ditto. (fhandler_pty_master::open): Ditto. (fhandler_pty_master::close): Ditto. Move some handling to cleanup(). (fhandler_pty_master::cleanup): New function. (fhandler_tty_master::init_console): Give unique name to captive console fhandler. * pinfo.cc (_pinfo::set_ctty): Rename argument from arch to fh. Eliminate archetype assumption. * syscalls.cc (close_all_files): Use close_with_arch for closing. (open): Use open_with_arch() rather than open(). (close): Use close_with_arch() rather than close().
2011-05-05* fhandler.cc (fhandler_base_overlapped::raw_read): Rename fromChristopher Faylor
read_overlapped. (fhandler_base_overlapped::raw_e): Rename from write_overlapped. * fhandler.h (fhandler_*::raw_read): Add reparm decoration. (fhandler_*::raw_write): Ditto. (fhandler_base_overlapped::raw_read): Rename from read_overlapped. (fhandler_base_overlapped::raw_write): Rename from write_overlapped. (fhandler_pipe::raw_read): Delete. (fhandler_pipe::raw_write): Ditto. (fhandler_mailslot::raw_read): Ditto. * fhandler_fifo.cc (fhandler_fifo::raw_read): Reflect read_overlapped -> raw_read rename. (fhandler_fifo::raw_write): Ditto. * fhandler_mailslot.cc (fhandler_mailslot::raw_read): Delete. (fhandler_mailslot::raw_write): Reflect read_overlapped -> raw_read rename. * pipe.cc (fhandler_pipe::raw_read): Delete. (fhandler_pipe::raw_write): Ditto.
2011-05-05 * fhandler.cc (is_at_eof): Drop static storage class. Drop errCorinna Vinschen
parameter since we don't change the Win32 error here anymore. (fhandler_base::raw_read): Accommodate change to is_at_eof. * fhandler_disk_file.cc (fhandler_disk_file::pread): In binary mode use direct call to NtReadFile, rather than lseek/read. (fhandler_disk_file::pwrite): In binary mode use direct call to NtWriteFile, rather than lseek/write.
2011-05-03 * fhandler.cc (fhandler_base_overlapped::wait_overlapped): MakeCorinna Vinschen
cancelable. Remove test for main thread, always add signal_arrived to waited objects.
2011-04-29 * ntdll.h (IsEventSignalled): New inline function.Corinna Vinschen
* cygthread.cc (cygthread::terminate_thread): Use IsEventSignalled in place of WaitForSingleObject on event with 0 timeout. * fhandler.cc (fhandler_base_overlapped::has_ongoing_io): Ditto. * fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait): Ditto. * fhandler_termios.cc (fhandler_termios::bg_check): Ditto. * select.cc (verify_tty_slave): Ditto. * thread.cc (pthread::testcancel): Ditto.
2011-03-13* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Remove specialChristopher Faylor
treatment for ERROR_NO_SYSTEM_RESOURCES. Cancel I/O and reset the overlapped handle on error. (fhandler_base_overlapped::write_overlapped): Limit writes to max_atomic_write bytes in blocking case. Incorporate code from now-defunct write_overlapped_fallback. Fix serious oversight where ptr was not advanced as buffer was written. (fhandler_base_overlapped::write_overlapped_fallback): Eliminate. * fhandler.h (fhandler_base_overlapped::write_overlapped_fallback): Ditto for declaration. (DEFAULT_PIPEBUFSIZE): Lower size to slightly less than documented worst-case atomic write size. (fhandler_overlapped::wait_return): Remove unused element.