summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/pipe.cc
Commit message (Collapse)AuthorAgeFilesLines
* Fix previous fix for generating unique inode numbers for socketsCorinna Vinschen2016-01-111-6/+6
| | | | | | | | | | | | * fhandler.h (fhandler_base::get_plain_ino): New inline method. Add comment to explain what it's supposed to be used for. * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Create filename using inode number. (fhandler_socket::fstat): Generate inode number from filename if ino is not set (that's the case in a stat(2) call). * pipe.cc: Throughout, use get_plain_ino when appropriate. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Return unique inode numbers when calling stat/fstat on pipes and IP socketsCorinna Vinschen2016-01-111-32/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fhandler.h (class fhandler_base): Convert unique_id to int64_t. (fhandler_base::set_ino): New protected inline method. (fhandler_base::get_unique_id): Convert to int64_t. (fhandler_base::set_unique_id): New inline method taking int64_t. (fhandler_pipe::fstat): Declare. (fhandler_pipe::init): Take extra parameter. (fhandler_pipe::create): Ditto. * fhandler_socket.cc (fhandler_socket::init_events): Set inode number to serial number. (fhandler_socket::fstat): Set device to DEV_TCP_MAJOR. Create st_ino from get_ino. * include/cygwin/signal.h (struct _sigcommune): Replace _si_pipe_fhandler with _si_pipe_unique_id. * pinfo.h (_pinfo::pipe_fhandler): Take unique id instead of HANDLE. * pinfo.cc (commune_process): Accommodate change to _si_pipe_unique_id. (_pinfo::commune_request): Ditto. (_pinfo::pipe_fhandler): Ditto. * pipe.cc (fhandler_pipe::init): Take unique id as argument and set inode number and unique_id from there. (fhandler_pipe::open): Rework to find any matching pipe from unique id in filename. (fhandler_pipe::get_proc_fd_name): Create filename using inode number. (fhandler_pipe::create): Generate and return unique id from process pid and pipe_unique_id. In outer method, call init with additional unique id as parameter. (fhandler_pipe::fstat): New method. (pipe_worker): Accommodate using 64 bit inode number in filename. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* * path.h (path_conv): Make path_flags private. Rename known_suffix toCorinna Vinschen2015-02-151-3/+3
| | | | | | | | | | | | | | suffix and make private. Rename normalized_path to posix_path and make privtae. Accommodate name changes throughout in path_conv methods. (path_conv::known_suffix): New method. Use throughout instead of accessing suffix directly. (path_conv::get_win32): Constify. (path_conv::get_posix): New method to read posix_path. Use throughout instead of accessing normalized_path directly. (path_conv::set_posix): Rename from set_normalized_path. Accommodate name change throughout. * spawn.cc (find_exec): Return POSIX path, not Win32 path.
* Throughout, (mainly in fhandler*) fix remaining gcc 4.7 mismatchYaakov Selkowitz2013-05-011-1/+1
| | | | | | | | | warnings between regparm definitions and declarations. * smallprint.cc (__small_vswprintf): Conditionalize declaration and setting of l_opt for only x86_64. * spawn.cc (child_info_spawn::worker): Remove unused 'pid' variable. * thread.cc (verifyable_object_isvalid): Temporarily define as non-inline with gcc 4.7+, regardless of target.
* * Merge in cygwin-64bit-branch.Corinna Vinschen2013-04-231-16/+18
|
* Throughout, change __attribute__ ((regparm (N))) to just __regN. Throughout,Christopher Faylor2013-01-211-1/+1
| | | | | | | | | | | | | | | | | | | (mainly in fhandler*) start fixing gcc 4.7.2 mismatch between regparm definitions and declarations. * gendef: Define some functions to take @ declaration to accommodate _regN defines which use __stdcall. * gentls_offsets: Define __regN macros as empty. * autoload.cc (wsock_init): Remove unneeded regparm attribute. * winsup.h (__reg1): Define. (__reg2): Define. (__reg3): Define. * advapi32.cc (DuplicateTokenEx): Coerce some initializers to avoid warnings from gcc 4.7.2. * exceptions.cc (status_info): Declare struct to use NTSTATUS. (cygwin_exception::dump_exception): Coerce e->ExceptionCode to NTSTATUS. * fhandler_clipboard.cc (cygnativeformat): Redefine as UINT to avoid gcc 4.7.2 warnings. (fhandler_dev_clipboard::read): Ditto.
* * DevNotes: Add entry cgf-000005.Christopher Faylor2012-05-121-5/+5
| | | | | | | * fhandler.h (PIPE_ADD_PID): Redefine to something we actually DON'T use. * pipe.cc (fhandler_pipe::create): Avoid clearing all open_mode bits when checking for PIPE_ADD_PID. Properly keep track of len so that passed in name is not overwritten.
* * fhandler.h (PIPE_ADD_PID): Define new flag.Christopher Faylor2012-04-301-3/+8
| | | | | | | * pipe.cc (fhandler_pipe::create): Don't indiscriminately add process id to every pipe since some pipe names (fifo, tty) don't need it. * sigproc.cc (sigproc_init): Pass PIPE_ADD_PID to fhandler_pipe::create to ensure that pid is always part of sigwait pipe name.
* * environ.cc (struct parse_thing): Add temporary (?) "pipe_byte" option.Christopher Faylor2012-04-281-9/+17
| | | | | | | | | * globals.cc (pipe_byte): Declare. * pipe.cc (fhandler_pipe::create): Use current process id in pipe name rather than pid for simple name collision avoidance. Do this only once to avoid extra overhead when a busy pipe is found. Honor pipe_byte to create non-message pipes if set. * sigproc.cc (sigproc_init): Use a specific name for the signal pipe.
* * cygheap.cc (init_cygheap::init_installation_root): Convert functionCorinna Vinschen2012-02-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | init_installation_root into a cygheap method. * cygheap.h (struct init_cygheap): Move installation_root, installation_key, and installation_key_buf from shared .cygwin_dll_common DLL section to cygheap. Declare new method init_installation_root. * dtable.cc (handle_to_fn): Accommodate the move of installation strings to the cygheap. * external.cc (cygwin_internal): Ditto. * fhandler_console.cc (fhandler_console::open_shared_console): Ditto. * fhandler_mailslot.cc (fhandler_mailslot::get_object_attr): Ditto. * fhandler_tty.cc: Ditto, throughout. * mount.cc (mount_info::init): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. * shared.cc: Ditto, throughout. (installation_root): Remove. (installation_key): Move to cygheap. (installation_key_buf): Ditto. (installation_root_inited): Remove. (SPIN_WAIT): Remove. (init_installation_root): Move to cygheap. (memory_init): Call cygheap->init_installation_root right after cygheap->user.init. Drop call of init_installation_root function. * shared_info.h (init_installation_root): Drop declaration. (installation_root): Ditto. (installation_key): Ditto. * uinfo.cc (pwdgrp::load): Accommodate the move of installation strings to the cygheap.
* * fhandler.h (fhandler_fifo::arm): Declare new function.Christopher Faylor2012-01-221-2/+2
| | | | | | | | | * fhandler_fifo.cc (fhandler_fifo::arm): Define new function. (fhandler_fifo::open): Fix handling of RDWR pipes to avoid opening a second handle. Use arm() function to set events. (fhandler_fifo::raw_read): Correctly go into "connect again logic" when we detect another writer is available. Use arm() function to set event. * pipe.cc (fhandler_pipe::create): Add more detail to debugging output.
* Clean up whitespace.Christopher Faylor2011-12-171-1/+1
|
* * pipe.cc (fhandler_pipe::create): Use debug_printf to print debugging infoChristopher Faylor2011-12-121-6/+41
| | | | | | | | | since this isn't a "syscall". (pipe_worker): New function created from _pipe(). (_pipe): Use pipe_worker to create a pipe. Use standard syscall strace reporting on exit. (pipe): Ditto. (pipe2): Ditto.
* Throughout, remove extra space after function name from debugging output.Christopher Faylor2011-12-031-1/+1
| | | | | | | | | | | | | | | 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.
* * pipe.cc (fhandler_pipe::create): Avoid derefencing a NULL pointer.Christopher Faylor2011-11-231-2/+2
| | | | | | | | | * 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.
* * fhandler.h (fhandler_pipe::create): Rename from the misnamedChristopher Faylor2011-11-231-5/+5
| | | | | | | | | | | | | | | | "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.
* * fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, takeChristopher Faylor2011-10-301-34/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * fhandler_tty.cc (fhandler_pty_slave::read): Use consistent way for testingChristopher Faylor2011-10-231-2/+8
| | | | | | 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.
* * cygerrno.h (__set_errno): Modify debugging output to make searching straceChristopher Faylor2011-10-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * pipe.cc (pipe): Just call _pipe with O_BINARY mode. Move code toCorinna Vinschen2011-08-151-19/+5
| | | | | generate normalized pathnames from here... (_pipe): ...to here.
* * miscfuncs.cc (create_pipe): Delete obsolete function.Christopher Faylor2011-08-121-1/+0
| | | | | * miscfuncs.h (create_pipe): Delete define. * pipe.c (fhandler_pipe::create_selectable): Delete obsolete comment.
* * dtable.cc (fh_oom): New static fhandler storage.Corinna Vinschen2011-06-301-6/+10
| | | | | | | | | | | | (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.
* * dtable.cc (dtable::select_write): Add missing argument to debug_printf.Christopher Faylor2011-05-311-0/+1
| | | | | | | | | | | | | | | * 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.
* * fhandler.cc (fhandler_base_overlapped::raw_read): Rename fromChristopher Faylor2011-05-051-12/+0
| | | | | | | | | | | | | | | | | | | 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.
* * fhandler.h (class fhandler_base): Remove uninterruptible_io statusCorinna Vinschen2011-05-041-3/+0
| | | | | | | | | | | | | | | | | | | | | flag. (fhandler_base::ready_for_read): Remove declaration. (fhandler_socket::ready_for_read): Ditto. (fhandler_pipe::ready_for_read): Ditto. (fhandler_tty_master::is_slow): Remove. * fhandler_console.cc (fhandler_console::open): Drop setting uninterruptible_io. * fhandler_serial.cc (fhandler_serial::open): Ditto. * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Ditto. (fhandler_tty_master::init_console): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Ditto. (fhandler_pipe::open): Ditto. (_pipe): Ditto. * select.cc (fhandler_pipe::ready_for_read): Remove. (fhandler_base::ready_for_read): Remove. * syscalls.cc (readv): Drop unneeded wait variable. Remove entire test which might lead to calling ready_for_read. Remove now unused label out.
* * errno.cc (errmap): Change mapping of NO_SYSTEM_RESOURCES to EFBIG.Christopher Faylor2011-03-091-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fhandler.cc (MAX_OVERLAPPED_WRITE_LEN): New constant. (MIN_OVERLAPPED_WRITE_LEN): Ditto. (fhandler_base_overlapped::close): Accommodate change in arguments to wait_overlapped. (fhandler_base_overlapped::setup_overlapped): Add __stdcall and regparm modifiers. (fhandler_base_overlapped::destroy_overlapped): Ditto. (fhandler_base_overlapped::has_ongoing_io): Ditto. (fhandler_base_overlapped::wait_overlapped): Modify to return an enum returning various states. Accept nonblocking parameter. (fhandler_base_overlapped::read_overlapped): Add __stdcall and regparm modifiers. Rework to attempt to be smarter about reacting to states returned by wait_overlapped. (fhandler_base_overlapped::write_overlapped): Ditto. Add fallback option for when wait_overlapped detects that smaller chunks must be written. (fhandler_base_overlapped::write_overlapped_fallback): Ditto. * fhandler.h (DEFAULT_PIPEBUFSIZE): Move definition here from pipe.cc. (fhandler_base::has_ongoing_io): Define with __stdcall and regparm modifiers. (fhandler_base_overlapped::wait_return): New enum. (fhandler_base_overlapped::max_atomic_write): New variable. (fhandler_base_overlapped:: wait_overlapped): Accommodate changes mentioned above to arguments and modifiers. (fhandler_base_overlapped::setup_overlapped): Ditto for modifiers. (fhandler_base_overlapped::read_overlapped): Ditto. (fhandler_base_overlapped::write_overlapped): Ditto. (fhandler_base_overlapped::destroy_overlapped): Ditto. (fhandler_base_overlapped::has_ongoing_io): Ditto. (fhandler_base_overlapped::fhandler_base_overlapped): Zero max_atomic_write. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Set max_atomic_write to the size of the DEFAULT_PIPEBUFSIZE. (fhandler_fifo::wait): Accommodate change in arguments to wait_overlapped. * pipe.cc (fhandler_pipe::fhandler_pipe): Set max_atomic_write to the size of the DEFAULT_PIPEBUFSIZE. (fhandler_pipe::create_selectable): Allow minimum size of DEFAULT_PIPEBUFSIZE. (DEFAULT_PIPEBUFSIZE): Delete here, move to fhandler.h.
* * pipe.cc (fhandler_pipe::open): Duplicate content of opened pipeCorinna Vinschen2010-08-141-0/+3
| | | | fhandler before calling dup method.
* * fhandler.h (fhandler_base::setup_overlapped): Delete virtual declaration.Christopher Faylor2010-04-021-2/+5
| | | | | | | | | | | | | | | | | | (fhandler_base::destroy_overlapped): Ditto. (fhandler_base_overlapped): Remove now-unneeded friend. (fhandler_base_overlapped::setup_overlapped): Return int, remove parameter. (fhandler_base_overlapped::get_overlapped): Return reference. (fhandler_base_overlapped::fhandler_base_overlapped): Be more assertive about zeroing everything. (fhandler_base_overlapped::fixup_after_fork): Declare new function. (fhandler_base_overlapped::fixup_after_exec): Ditto. (fhandler_base_overlapped::dup): Ditto. (fhandler_base_overlapped::close): Ditto. * fhandler_fifo.cc (fhandler_fifo::dup): Call fhandler_base_overlapped::dup rather than fhandler_base::dup. * pipe.cc (fhandler_pipe::dup): Ditto. (fhandler_pipe::init): Accommodate change in setup_overlapped arguments for "opened_properly" case.
* * fhandler.cc (fhandler_base::dup): Call setup_overlapped unconditionally.Christopher Faylor2010-03-311-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | (fhandler_base::fork_fixup): Ditto. (fhandler_base::fixup_after_fork): Ditto. (fhandler_base::fixup_after_exec): Ditto. (fhandler_base_overlapped::setup_overlapped): Move to this class from fhandler_base. (handler_base_overlapped::destroy_overlapped): Ditto. (fhandler_base_overlapped::wait_overlapped): Ditto. Track when we expect pending I/O. (fhandler_base_overlapped::read_overlapped): Move to this class from fhandler_base. Return error if ongoing I/O. (fhandler_base_overlapped::write_overlapped): Ditto. (fhandler_base_overlapped::has_ongoing_io): Semi-reinstate previous function. * fhandler.h (fhandler_base::wait_overlapped): Move to fhandler_base_overlapped class. (fhandler_base::write_overlapped): Ditto. (fhandler_base::get_overlapped): Ditto. (fhandler_base::get_overlapped_buffer): Ditto. (fhandler_base_overlapped): New class. (fhandler_pipe): Inherit from fhandler_base_overlapped. Remove overlapped stuff as a result. (fhandler_fifo): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Initialize fhandler_base_overlapped. (pipe): Put a descriptive name in the fhandler.
* * libc/strfmon.c (__setup_vars): Fix compiler warning about assigning constChristopher Faylor2010-01-291-1/+1
| | | | | | strings. Compare a pointer to NULL rather than '\0'. * dll_init.cc (dll_dllcrt0_1): Minor comment fix. * pipe.cc (fhandler_pipe::create_selectable): Remove Win9x accommodation.
* * cygwin.din (dup3): Export.Corinna Vinschen2010-01-141-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (pipe2): Export. * dtable.cc (dtable::dup_worker): Take additional flags parameter. Handle O_CLOEXEC flag. (dtable::dup3): Rename from dup2. Take additional flags parameter. Check for valid flags. Drop check for newfd == oldfd. * dtable.h (dtable::dup_worker): Add flags parameter. (dtable::dup3): Rename from dup2. * fcntl.cc (fcntl64): Add F_DUPFD_CLOEXEC case. * fhandler.h (fhandler_mailslot::get_object_attr): Add flags parameter. * fhandler.cc (fhandler_base::open): Use security attribute with inheritance according to setting of O_CLOEXEC flag. * fhandler_console.cc (fhandler_console::open): Ditto. * fhandler_fifo.cc (sec_user_cloexec): New inline function to create security attribute with inheritance according to setting of O_CLOEXEC flag. (fhandler_fifo::open): Call sec_user_cloexec to fetch security attribute. (fhandler_fifo::wait): Ditto. * fhandler_mem.cc (fhandler_dev_mem::open): Ditto. * fhandler_mailslot.cc (fhandler_mailslot::get_object_attr): Take additional flags parameter. Use security attribute with inheritance according to setting of O_CLOEXEC flag. (fhandler_mailslot::open): Call get_object_attr with flags parameter. * fhandler_registry.cc (fhandler_registry::open): Call set_close_on_exec on real handles to accommodate O_CLOEXEC flag. * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. * fhandler_tape.cc: Create mutex with inheritance according to setting of O_CLOEXEC flag. * pipe.cc: Replace usage of O_NOINHERIT with O_CLOEXEC. (fhandler_pipe::init): Simplify setting close_on_exec flag. (fhandler_pipe::open): Remove setting close_on_exec flag. (fhandler_pipe::create): Use security attribute with inheritance according to setting of O_CLOEXEC flag. (pipe2): New exported function. * posix_ipc.cc: Throughout, open backing files with O_CLOEXEC flag to follow POSIX semantics. * security.h (sec_none_cloexec): New define. * syscalls.cc (dup): Add missing extern "C" qualifier. Accommodate renaming of dtable::dup2 to dtable::dup3. (dup2): Ditto. Check newfd == oldfd here. (dup3): New function. Check newfd == oldfd here. (open): Set close_on_exec flag according to O_CLOEXEC flag before calling fhandler->open. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* Throughout, replace hMainProc with GetCurrentProcess/NtCurrentProcessCorinna Vinschen2009-12-181-1/+1
| | | | | | | | | | | | according to context. Throughout, replace hMainThread with GetCurrentThread/NtCurrentThread according to context. * dcrt0.cc (dll_crt0_0): Drop duplication of GetCurrentProcess to hMainProc. Drop duplication of GetCurrentThread to hMainThread. * dtable.cc (dtable::stdio_init): Remove useless comment. * globals.cc (hMainProc): Remove. (hMainThread): Remove. * ntdll.h (NtCurrentProcess): Define. (NtCurrentThread: Define.
* * fhandler_fifo.cc (fhandler_fifo::open): Avoid resetting errno after it hasChristopher Faylor2009-12-091-1/+1
| | | | | been explicitly set. * include/cygwin/version.h: Bump DLL minor version number to 2.
* * cygprops.h: New file.Corinna Vinschen2009-10-311-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dtable.cc (handle_to_fn): Add check for correct installation_key string in object name for pipes and ttys. * external.cc (cygwin_internal): Add CW_GET_INSTKEY to allow fetching the installation_key from cygserver. * fhandler_fifo.cc (fhandler_fifo::fifo_name): Add installation_key to fifo name. * globals.cc: Include cygprops.h. (_RDATA): Move slightly and add comment. (cygwin_props): Define. * mount.cc (mount_info::init): Accommodate the fact that installation_root is now a global variable in DLL common shared memory, rather than a member of cygwin_shared. * pipe.cc (fhandler_pipe::create_selectable): Add installation_key to pipe name. * shared.cc (installation_root): Define here for storage in DLL common shared memory. (installation_key): Ditto. (installation_key_buf): Ditto. (init_installation_root): Convert from shared_info method to ordinary function. Add initializing installation_key. Invalidate installation_key depending of value of disable_key property. Add comment to explain. (get_shared_parent_dir): Add installation_key to directory name. (get_session_parent_dir): Ditto. (shared_info::initialize): Move call to init_installation_root from here... (memory_init): ...to here. Add debug output to print installation root and installation key. Add comment to explain why. * shared_info.h (SHARED_INFO_CB): Recalculate. (CURR_SHARED_MAGIC): Ditto. (class shared_info): Remove definition of installation_root and declaration of init_installation_root. (init_installation_root): Declare. (installation_root): Declare. (installation_key): Declare. * uinfo.cc (pwdgrp::load): Accommodate the fact that installation_root is now a global variable in DLL common shared memory. * include/cygwin/version.h: Bump API minor number. (CYGWIN_INFO_INSTALLATIONS_NAME): Add. * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GET_INSTKEY.
* * pipe.cc (fhandler_pipe::create_selectable): Add -pipe to default pipe names.Christopher Faylor2009-08-171-1/+1
| | | | | * lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Use bool/true/false for what is actually a boolean variable.
* * fhandler.h (fhandler_cygdrive:DRVSZ): New enum.Christopher Faylor2009-08-041-5/+7
| | | | | | | | | | | (pdrive_buf): New place to hold information about cygdrive. * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Store drive info in pdrive_buf since get_win32_name() could now be too small to hold everything. (fhandler_cygdrive::rewinddir): Reset pdrive to pdrive_buf. (fhandler_cygdrive::closedir): Ditto. * pipe.cc (fhandler_pipe::init): Be more defensive when referencing get_win32_name(). Rework logic which made a copy of the POSIX path and then never used it.
* * dcrt0.cc (jit_debug): New global.Christopher Faylor2009-07-031-3/+4
| | | | | | | | | | | | | | | | | | | | | (initial_env): Set jit_debug when we are automatically starting a gdb process. * dtable.cc (dtable::get_debugger_info): Don't tty tricks when we are being debugged by our own captive gdb, as determined by jit_debug == true. (dtable::init_std_file_from_handle): Detect errors when initializing a tty early rather than at random points later. * fhandler.h (fhandler_*::init): Return int to indicate success/failure. * fhandler.cc (fhandler_base::init): Reflect change in return value. * pipe.cc (fhandler_pipe::init): Ditto. (fhandler_pipe::create_selectable): Don't say we're retrying when we aren't. * fhandler_console.cc (fhandler_console::init): Ditto. Return success/failure. * fhandler_serial.cc (fhandler_serial::init): Ditto. * fhandler_tty.cc (fhandler_tty_slave::init): Ditto. (fhandler_tty_slave::open): Make debugging output more detailed. * tty.cc (tty_list::terminate): Don't close I/O handles before all slaves have checked in. (tty::slave_alive): Make a non-inlined function. Check if tty pipe handles can be created as an additional exists check. * tty.h (tty::slave_alive): Just define here.
* * fhandler.cc (fhandler_base::wait_overlapped): Set bytes to -1 on EINTR orChristopher Faylor2009-01-271-0/+1
| | | | | | | | real error. (fhandler_base::write_overlapped): Assume that bytes_written will contain proper error value. * pipe.cc (fhandler_pipe::fhandler_pipe): Set uninterruptible_io since signals are handled by pipe functions now.
* * fhandler.h (fhandler_base_setup_overlapped): Add new argument.Christopher Faylor2008-12-231-133/+2
| | | | | | | | | | | | | | | | | | | | | | | (fhandler_base::get_overlapped_buffer): Declare new function. (fhandler_base::set_overlapped): Ditto. (fhandler_pipe::overlapped): New variable. (fhandler_pipe::get_overlapped): Rework to return contents of overlapped variable. (fhandler_pipe::set_overlapped): Set overlapped variable based on argument. (fhandler_fifo::get_overlapped_buffer): Return pointer to io_status. * fhandler.cc (handler_base::setup_overlapped): Set to overlapped pointer to NULL if new doit parameter is false. Otherwise set up overlapped event as usual. (fhandler_base::wait_overlapped): Return inres if this isn't an overlapped operation. (fhandler_base::read_overlapped): Remove inappropriate asserts. * pipe.cc (fhandler_pipe::fhandler_pipe): Zero overlapped element. (struct pipesync): Delete. (getov_result): Ditto. (pipe_handler): Ditto. (pipesync::pipesync): Ditto. (fhandler_pipe::init): Don't set up pipesync thread. Just pass opened_properly flag along to overlapped setup.
* * pipe.cc (getov_result): Minor cleanup.Christopher Faylor2008-12-221-3/+2
|
* * pipe.cc (getov_result): Add parameters to facilitate better EOF checking.Christopher Faylor2008-12-211-5/+9
| | | | (pipe_handler): Pass extra arguments to getov_result.
* * fhandler.h (fhandler_pipe::raw_read): Remove __stdcall decoration.Christopher Faylor2008-09-111-1/+1
| | | | * pipe.cc (fhandler_pipe::raw_read): Ditto.
* * cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error.Christopher Faylor2008-09-111-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
* * fhandler.h (class fhandler_pipe): Rename read and writeCorinna Vinschen2008-08-261-2/+2
| | | | | | declarations to raw_read and raw_write. * pipe.cc (fhandler_pipe::raw_read): Rename from read. (fhandler_pipe::raw_write): Rename from write.
* * fhandler.cc (fhandler_base::wait_overlapped): Always assume that bytes willChristopher Faylor2008-08-201-1/+1
| | | | | | | | | be non-NULL. Distinguish input result from result derived from WFMO and GetOverlappedResult or res can never be -1. Only raise SIGPIPE when writing. * fhandler.h (fhandler_base::wait_overlapped): Pass first argument by value. * fhandler_fifo.cc (fhandler_fifo::wait): Pass in dummy byte count to wait_overlapped. * pipe.cc (DEFAULT_PIPEBUFSIZE): Define to 65536 explicitly.
* * environ.cc (known): Remove "binmode" option.Corinna Vinschen2008-07-181-4/+1
| | | | | | | | * fhandler.cc (binmode): Remove. (fhandler_base::set_flags): Accommodate binmode removal. * path.h (path_conv::set_binary): Remove. * pipe.cc (pipe): Create pipes always as binary pipes. * winsup.h (binmode): Remove declaration.
* Remove unneeded header files from source files throughout.Christopher Faylor2008-04-071-5/+0
|
* * dtable.cc: Define various device-related string constants as wide characterChristopher Faylor2008-03-221-12/+25
| | | | | | | | | | | | | | | | | | | | | constants. (dtable::init_std_file_from_handle): Reorganize pipe handling to try to catch special tty case. (build_fh_name_worker): Declare for common use. (build_fh_name): Define char version. (build_fh_name): Define (currently unused) UNICODE_STRING version. (decode_tty): Detect if pipe is actually a cygwin tty, returning the tty name in the buffer. (handle_to_fn): Reorganize to use wide characters. * dtable.h (build_fh_name): Declare (currently unused) UNICODE_STRING version. * fhandler_tty.cc (fhandler_pty_master::setup): Use fhandler_pipe::create_selectable to create a pipe with a given name. * pipe.cc (pipe_handler): Make returned handle inheritable. (fhandler_pipe::create_selectable): Take an optional name. Use a standard cygwin introducer for the name. * path.cc (path_conv::check): Make first argument const. * path.h (path_conv::check): Ditto for declaration. (path_conv::path_conv): Ditto for UNICODE_STRING version.
* * pipe.cc (fhandler_pipe::create_selectable): Use MAX_PATH instead ofCorinna Vinschen2008-03-121-1/+1
| | | | | | | | | CYG_MAX_PATH. * tty.cc (tty_list::init_session): Ditto. (tty::alive): Ditto. (tty::open_mutex): Ditto. (tty::create_inuse): Ditto. (tty::get_event): Ditto.
* Perform whitespace cleanup throughout.Christopher Faylor2008-02-151-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dcrt0.cc (signal_shift_subtract): Eliminate ancient backwards compatibility. (check_sanity_and_sync): Ditto. * winsup.h (SIGTOMASK): Ditto. Just use constant in signal calculation. * include/cygwin/version: Remove backwards signal mask compatibility define. * path.cc (symlink_info::check_sysfile): Cosmetic change. * registry.cc (get_registry_hive_path): Remove unneeded variable. * exceptions.cc (handle_sigsuspend): Eliminate thread signal mask and use either main sigmask or current thread sigmask. (set_process_mask): Ditto. (sighold): Ditto. (sigrelse): Ditto. (sigset): Ditto. (set_process_mask_delta): Ditto. (_cygtls::call_signal_handler): Ditto. * fhandler_process.cc (format_process_status): Ditto. * fhandler_termios.cc (fhandler_termios::bg_check): Ditto. * pinfo.h (class pinfo): Ditto. * select.cc (pselect): Ditto. * signal.cc (sigprocmask): Ditto. (abort): Ditto. (sigpause): Ditto. (sigsend): Ditto. (wait_sig): Ditto. * thread.h (pthread::parent_tls): New member. * thread.cc (pthread::pthread): Record parent_tls here. (pthread::thread_init_wrapper): Initialize sigmask from parent thread.