summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_tty.cc
Commit message (Collapse)AuthorAgeFilesLines
* Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout optioncygwin-2_5_2-releaseCorinna Vinschen2016-06-231-3/+0
| | | | | | | | | | | | | | Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause. Everything else stays under GPLv3+. New Linking Exception exempts resulting executables from LGPLv3 section 4. Add CONTRIBUTORS file to keep track of licensing. Remove 'Copyright Red Hat Inc' comments. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Return at most one line of input in canonical modeTakashi Yano2016-06-061-6/+5
| | | | | | | | | | | | | | | | | 'man termios' says: "A read(2) returns at most one line of input" in canonical mode. On cygwin 2.5.1, read(2) returns all data in buffer if the buffer size specified is large enough. This behaviour is correct in noncanonical mode, but is not correct in canonical mode. While checking this problem, I found a bug of tcflush(). tcflush() flushes only partial data in the buffer. The patch also fixes this bug. The patch has also been tested against the problem reported in https://cygwin.com/ml/cygwin/2016-05/msg00318.html. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Revert "Cygwin hangs up if several keys are typed during outputting a lot of ↵Corinna Vinschen2016-06-011-1/+1
| | | | | | | | | texts." This reverts commit 252a07b0ad3353abcd0fcd9b1b65ff977acd679e. This change introduced a hang in certain scenarios, for an example see https://cygwin.com/ml/cygwin/2016-05/msg00318.html
* Implement POSIX.1e ACL functionsCorinna Vinschen2016-03-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.in (DLL_OFILES): Add sec_posixacl.o. (SUBLIBS): Add libacl.a (libacl.a): New rule to create libacl.a. * common.din: Export POSIX ACL functions as well as most libacl.a extensions. * fhandler.h (fhander_base::acl_get): New prototype. (fhander_base::acl_set): Ditto. (fhandler_disk_file::acl_get): Ditto. (fhandler_disk_file::acl_set): Ditto. * include/acl/libacl.h: New file. * include/cygwin/version.h: Bump API minor version. * include/sys/acl.h: Drop including cygwin/acl.h. Accommodate throughout Cygwin. Add POSIX ACL definitions. * sec_acl.cc: Include sec_posixacl.h. Replace ILLEGAL_UID and ILLEGAL_GID with ACL_UNDEFINED_ID where sensible. (__aclcheck): New internal acl check function to be used for Solaris and POSIX ACLs. (aclcheck32): Call __aclcheck. (__aclcalcmask): New function to compute ACL_MASK value. (__aclsort): New internal acl sort function to be used for Solaris and POSIX ACLs. (aclsort32): Call __aclsort. (permtostr): Work directly on provided buffer. (__acltotext): New internal acltotext function to be used for Solaris and POSIX ACLs. (acltotext32): Call __acltotext. (__aclfromtext): New internal aclfromtext function to be used for Solaris and POSIX ACLs. (aclfromtext32): Call __aclfromtext. * sec_posixacl.cc: New file implemeting POSIX ACL functions. * sec_posixacl.h: New internal header. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix file type mode bit handling on object security.Corinna Vinschen2015-11-181-6/+10
| | | | | | | | | | | | | | | * fhandler_tty.cc (fhandler_pty_slave::open): Add S_IFCHR flag in call to create_object_sd_from_attribute. (fhandler_pty_slave::fstat): Ditto in call to get_object_attribute. (fhandler_pty_slave::fchmod): Add an orig_mode flag and ditto for both calls. (fhandler_pty_master::setup): Ditto in call to create_object_sd_from_attribute. * security.cc (get_object_attribute): Never add S_IFCHR to mode here. Let the caller decide. (create_object_sd_from_attribute): Ditto. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Reapply POSIX ACL changes.Corinna Vinschen2015-11-181-11/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - New, unified implementation of POSIX permission and ACL handling. The new ACLs now store the POSIX ACL MASK/CLASS_OBJ permission mask, and they allow to inherit the S_ISGID bit. ACL inheritance now really works as desired, in a limited, but theoretically equivalent fashion even for non-Cygwin processes. To accommodate Windows default ACLs, the new code ignores SYSTEM and Administrators group permissions when computing the MASK/CLASS_OBJ permission mask on old ACLs, and it doesn't deny access to SYSTEM and Administrators group based on the value of MASK/CLASS_OBJ when creating the new ACLs. The new code now handles the S_ISGID bit on directories as on Linux: Setting S_ISGID on a directory causes new files and subdirs created within to inherit its group, rather than the primary group of the user who created the file. This only works for files and directories created by Cygwin processes. 2015-05-29 Corinna Vinschen <corinna@vinschen.de> Reapply POSIX ACL changes. * utils.xml (setfacl): Show new option output. (getfacl): Show new option output. * sec_acl.cc (get_posix_access): Check for Cygwin "standard" ACL. Apply umask, if so. Align comments. * security.cc (set_created_file_access): Fix permission masking by incoming requested file mode. * sec_acl.cc (set_posix_access): Apply mask only in terms of execute bit for SYSTEM and Admins group. * sec_acl.cc (set_posix_access): Don't create DENY ACEs for USER and GROUP entries if they are the same as USER_OBJ or GROUP_OBJ. * fhandler.h (fhandler_pty_slave::facl): Add prototype. * fhandler_tty.cc (fhandler_pty_slave::facl): New method. (fhandler_pty_slave::fchown): Fix uid/gid handling. * sec_acl.cc (set_posix_access): Drop superfluous class_idx variable. Simplify and move around code in a few places. To improve ACL readability, add r/w permissions to Admins ACE appended to pty ACL. Add comment to explain Windows ACE Mask filtering being in the way of creating a real CLASS_OBJ. (get_posix_access): Fake CLASS_OBJ for ptys. Explain why. * security.cc (get_object_attribute): Add S_IFCHR flag to attributes when calling get_posix_access. * sec_acl.cc (set_posix_access): Move merging group perms into owner perms in case of owner == group after mask has been computed. Take mask into account when doing so to avoid unnecessary ACCESS_DENIED_ACE. * sec_acl.cc (get_posix_access): Only set saw_group_obj flag if we saw the ACCESS_ALLOWED_ACE. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Deliberatly set GROUP_OBJ and CLASS_OBJ perms to new group perms. Add comment to explain why. * security.cc (set_created_file_access): Ditto. * sec_acl.cc (set_posix_access): Replace previous patch. Return EINVAL if uid and/or guid is invalid and not backed by an actual Windows account. * sec_acl.cc (set_posix_access): Workaround owner/group SIDs being NULL. * sec_acl.cc (set_posix_access): Handle files with owner == group. Rephrase switch statement checking against unfiltered a_type value. (get_posix_access): Handle files with owner == group. * sec_acl.cc (get_posix_access): Don't use GROUP_OBJ access to fix up CLASS_OBJ mask on old-style ACLs. Fix a comment. * sec_acl.cc (set_posix_access): Always make sure Admins have WRITE_DAC and WRITE_OWNER permissions. * security.h (create_object_sd_from_attribute): Drop handle parameter from prototype. * security.cc (create_object_sd_from_attribute): Drop handle parameter. Just create the standard POSIXy security descriptor. (set_object_attribute): Accommodate dropped paramter in call to create_object_sd_from_attribute. * fhandler_tty.cc: Ditto, throughout. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Fix typo in mask computation. * fhandler.cc (fhandler_base::open_with_arch): Call open with mode not umasked. (fhandler_base::open): Explicitely umask mode on NFS here. Call new set_created_file_access rather than set_file_attribute. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Reimplement setting permissions on filesystems supporting ACLs using the new set_posix_access call. (fhandler_disk_file::fchown): Ditto. (fhandler_disk_file::mkdir): Call new set_created_file_access rather than set_file_attribute. * fhandler_socket.cc (fhandler_socket::bind): Don't umask here. Add WRITE_OWNER access to allow writing group in case of SGID bit set. Call new set_created_file_access rather than set_file_attribute. * path.cc (symlink_worker): Call new set_created_file_access rather than set_file_attribute. * sec_acl.cc (searchace): Un-staticize. (set_posix_access): New, complementary functionality to get_posix_access. (setacl): Implement in terms of get_posix_access/set_posix_access. (get_posix_access): Add handling for just created files requiring their first Cygwin ACL. Fix new_style recognition. Handle SGID bit. For old-style ACLs, ignore SYSTEM and Administrators when computing the {DEF_}CLASS_OBJ perms. * security.cc (get_file_sd): Revamp comment. Change and (hopefully) speed up inheritance processing for just created files. (alloc_sd): Remove. (set_security_attribute): Call set_posix_access instead of alloc_sd. (get_object_attribute): Fix return value. (create_object_sd_from_attribute): Call set_posix_access instead of alloc_sd. (set_file_attribute): Remove. (set_created_file_access): New function implemented in terms of get_posix_access/set_posix_access. * security.h (set_file_attribute): Remove prototype. (set_created_file_access): Add prototype. (searchace): Ditto. (set_posix_access): Ditto. * syscalls.cc (open): Call open_with_arch with mode not umasked. * sec_acl.cc: Change preceeding comment explaining new-style ACLs. Describe how to generate deny ACEs in more detail. Accommodate the fact that a NULL deny ACE is used for {DEF_}CLASS_OBJ, rather than a special Cygwin ACE. Improve further comments. (CYG_ACE_NEW_STYLE): Define. (get_posix_access): Change from Cygwin ACE to NULL deny ACE. Fix CLASS_OBJ handling to generate CLASS_OBJ and DEF_CLASS_OBJ from a single NULL deny ACE if the inheritance flags say so. * sec_helper.cc (well_known_cygwin_sid): Remove. * security.h (well_known_cygwin_sid): Drop declaration. * sec_acl.cc (CYG_ACE_ISBITS_TO_WIN): Fix typo. (get_posix_access): Rename index variable from i to idx. Define only once at top level. * security.cc (add_access_allowed_ace): Drop unused parameter "offset". Accommodate throughout. (add_access_denied_ace): Ditto. * sec_acl.cc: Accommodate above change throughout. * security.h (add_access_allowed_ace): Adjust prototype to above change. (add_access_denied_ace): Ditto. * sec_acl.cc (get_posix_access): Handle multiple ACEs for the owner and primary group of the file. Handle the default primary group ACE as DEF_GROUP_OBJ entry if the directory has the S_ISGID bit set. Add comments. Minor code rearrangements. Preliminary read side implementation of new permission handling. * acl.h (MAX_ACL_ENTRIES): Raise to 2730. Add comment to explain. * sec_acl.cc: Add leading comment to explain new ACL style. Add definitions and macros to use for bits in new Cygwin ACL. (DENY_RWX): New mask value for all temporary deny bits. (getace): Add bool parameter to decide when leaving all bits intact, rather than filtering them per the already set bits. (get_posix_access): New function, taking over functionality to read POSIX ACL from SECURITY_DESCRIPTOR. (getacl): Just call get_posix_access. * sec_helper.cc (well_known_cygwin_sid): Define. * security.cc (get_attribute_from_acl): Remove. (get_info_from_sd): Remove. (get_reg_sd): Call get_posix_access instead of get_info_from_sd. (get_file_attribute): Ditto. (get_object_attribute): Ditto. * security.h (well_known_cygwin_sid): Declare. (get_posix_access): Add prototype. * Throughout, use simpler ACE macros from Windows' accctrl.h. * getfacl.c (main): Special-case SYSTEM and Admins group. Add comments. * setfacl.c: Align more to Linux tool. (delacl): New function to delete acl entries only. (modacl): Drop delete functionality. Add handling of recomputing the mask and default mask values. (delallacl): Rename from delacl. (setfacl): Call delacl in Delete case. Call delallacl in DeleteAll and DeleteDef case. (usage): Accommodate new options. Rearrange and rephrase slightly. (longopts): Emit 'x' in --delete case. Add --no-mask and --mask options. (opts): Add -x and -n options. (main): Handle -d and -x the same. Handle -n and --mask options. Drop handling for -r option. * getfacl.c (usage): Align more closely to Linux version. Add new options -c, -e, -E. Change formatting to accommodate longer options. (longopts): Rename --noname to --numeric. Keep --noname for backward compatibility. Add --omit-header, --all-effective and --no-effective options. (opts): Add -c, -e and -E option. (main): Handle new -c, -e, and -E options. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Generate SIGHUP for terminal process group on tty master closeTakashi Yano2015-06-081-6/+18
| | | | | | | | | * fhandler_tty.cc (fhandler_pty_slave::write): Move causing of SIGHUP into fhandler_pty_master::close(). (fhandler_pty_slave::read): Ditto. (fhandler_pty_master::close): Ditto. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Use NtQueryObject to detect closing the last master handleCorinna Vinschen2015-05-281-8/+21
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix closing too many handles in pty fchown/fchmodCorinna Vinschen2015-04-231-3/+0
| | | | | | | * fhandler_tty.cc (fhandler_pty_slave::fch_close_handles): Don't close handles not opened via fhandler_pty_slave::fch_open_handles. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix OPOST for non-Cygwin pty slavesTakashi Yano2015-04-231-17/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fhandler.h (class fhandler_base): Add virtual function get_io_handle_cyg() to get handle from which OPOST-processed output is read on PTY master. (class fhandler_pty_slave): Add variable output_handle_cyg to store a handle to which OPOST-processed output is written. Add two functions, i.e., set_output_handle_cyg() and get_output_handle_cyg(), regarding variable output_handle_cyg. Now, output_handle is used only by native windows program. The data before OPOST-processing is written to output_handle and OPOST-processing is applied in the master-side. For a cygwin process, OPOST-processing is applied in the slave-side, and the data after OPOST-processing is written to output_handle_cyg. (class fhandler_pty_master): Add two variables, i.e., io_handle_cyg and to_master_cyg, to store handles of a pipe through which OPOST-processed output passes. Add pty_master_fwd_thread and function pty_master_fwd_thread() for a thread which applies OPOST-processing and forwards data from io_handle to to_master_cyg. Add function get_io_handle_cyg() regarding variable io_handle_cyg. Now, the pipe between io_handle and to_master are used only by native windows program for applying OPOST-processing in the master-side. For a cygwin process, the pipe between io_handle_cyg and to_master_cyg is used for passing through the data which is applied OPOST-processing in the slave-side. * fhandler_tty.cc (struct pipe_reply): Add member to_master_cyg. (fhandler_pty_master::process_slave_output): Read slave output from io_handle_cyg rather than io_handle. (fhandler_pty_slave::fhandler_pty_salve): Initialize output_handle_cyg. (fhandler_pty_slave::open): Set output_handle_cyg by duplicating handle to_master_cyg on PTY master. (fhandler_pty_slave::close): Close handle output_handle_cyg. (fhandler_pty_slave::write): Write data to output_handle_cyg rather than output_handle. (fhandler_pty_slave::fch_close_handles): Close handle output_handle_cyg. (fhandler_pty_master::fhandler_pty_master): Initialize io_handle_cyg, to_master_cyg and master_fwd_thread. (fhandler_pty_master::cleanup): Clean up to_master_cyg as well. (fhandler_pty_master::close): Print to_master_cyg as well in debug message. Terminate master forwarding thread. Close handles to_master_cyg and io_handle_cyg. (fhandler_pty_master::ioctl): Use io_handle_cyg rather than to_master. (fhandler_pty_master::pty_master_thread): Add code for duplicating handle to_master_cyg. (fhandler_pty_master::pty_master_fwd_thread): New function for a thread to forward OPOST-processed data from io_handle to to_master_cyg. This thread applies OPOST-processing to the output of native windows program. (::pty_master_fwd_thread): Ditto. (fhandler_pty_master::setup): Create a new pipe to pass thruegh OPOST- processed output. Create new thread to forward data from io_handle to to_master_cyg. Set handle to_master_cyg to tty. Print io_handle_cyg as well in debug message. Close handles io_handle_cyg and to_master_cyg in case of error. (fhandler_pty_master::fixup_after_fork): Set handle to_master_cyg to tty. Copy handle to_master_cyg from arch->to_master_cyg. (fhandler_pty_master::fixup_after_exec): Clean up to_master_cyg. * select.cc: Check handle returned by get_io_handle_cyg() rather than get_handle(). * tty.h (class tty): Add variable _to_master_cyg to store a handle to which OPOST-processed data is written. Add two functions, to_master_cyg() and set_to_master_cyg(), regarding _to_master_cyg. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin hangs up if several keys are typed during outputting a lot of texts.Takashi Yano2015-04-231-1/+1
| | | | | | | * fhandler_tty.cc (fhandler_pty_slave::read): Change calculation of "readlen" not to use "bytes_in_pipe" value directly. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* TIOCPKT mode of PTY is broken if ONLCR bit is cleared.Takashi Yano2015-04-231-124/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tty.h (class tty_min): Remove variable "write_error" to which any errors are not currently set at anywhere. (class tty): Add variable "column" for handling ONOCR. * tty.cc (tty::init): Add initialization code for variable "column". * fhandler.h (class fhandler_pty_master): Remove variable "need_nl" which is not necessary any more. "need_nl" was needed by OPOST process in fhandler_pty_master::process_slave_output(). (class fhandler_pty_common): Add function process_opost_output() for handling post processing for OPOST in write process. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Count TIOCPKT control byte into length to be read in TIOCPKT mode. Move post processing for OPOST to write process. Remove code related to variable "write_error". Return with EIO error if slave is already closed. (fhandler_pty_master::fhandler_pty_master): Remove initialization code for variable "need_nl". (fhandler_pty_common::process_opost_output): Add this function for handling of OPOST in write process. Add code to avoid blocking in non-blocking mode when output is suspended by ^S. (fhandler_pty_slave::write): Call fhandler_pty_common:: process_opost_output() instead of WriteFile(). Remove code related to variable "write_error". (fhandler_pty_master::doecho): Call fhandler_pty_common:: process_opost_output() instead of WriteFile(). * select.cc (peek_pipe): Remove code related to variable "need_nl". Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Let pty slave detect closure of last master handleTakashi Yano2015-03-121-3/+9
| | | | | | | * fhandler_tty.cc (fhandler_pty_master::close): Add code to make slave detect closure of master. Fix typo in error message. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* * tty.h (tty::set_master_ctl_closed): Rename from set_master_closed.Corinna Vinschen2015-03-051-20/+11
| | | | | | | | | | (tty::is_master_closed): Drop method. * fhandler_tty.cc (fhandler_pty_slave::open): Remove code prematurely bailing out if master control thread is not running. (fhandler_pty_slave::read): Don't generate SIGHUP if master control thread is not running. (fhandler_pty_master::close): Rearrange code to avoid stopping master control thread twice in multi-threaded scenarios.
* * fhandler.h (fhandler_base::get_echo_handle): New virtual method.Corinna Vinschen2015-03-051-10/+33
| | | | | | | | | | | | | | | | (class fhandler_pty_master): Add echo_r and echo_w handles constituting read and write side of new echo pipe. * select.cc (peek_pipe): On pty masters, check additionally if input from the echo pipe is available. * fhandler_tty.cc (fhandler_pty_master::doecho): Drop output_mutex locking. Write output to echo pipe. (fhandler_pty_master::process_slave_output): Check if input is available in echo pipe and prefer to read from it, if so. (fhandler_pty_slave::write): Drop output_mutex locking. (fhandler_pty_master::fhandler_pty_master): Initialize echo pipe handles to NULL. (fhandler_pty_master::close): Close and NULL echo pipe handles. (fhandler_pty_master::setup): Create echo pipe, close in case of error.
* * fhandler_tty.cc (fhandler_pty_slave::read): Having no input is not anCorinna Vinschen2015-02-251-2/+3
| | | | error condition for tcflush.
* * fhandler.h (fhandler_termios::line_edit): Add parameter to returnCorinna Vinschen2014-11-131-13/+10
| | | | | | | | | | | | | | written bytes. * fhandler_termios.cc (fhandler_termios::tcinit): Fix formatting. (fhandler_termios::line_edit): Return bytes actually written. Write in 32 byte chunks in non-canonical mode to reduce number of WriteFile calls. Don't just eat unwritten bytes in case of an error condition. Especially, don't report them back to the caller as written. * fhandler_tty.cc (fhandler_pty_slave::read): Disable code reducing the number of bytes read from the pipe to vmin. Add comment. (fhandler_pty_master::write): Convert ret to ssize_t type. Just call line_edit once, not in a loop once for each byte. Return bytes written as returned by line_edit.
* * fhandler.h (fhandler_pty_slave::fch_open_handles): Add bool parameterCorinna Vinschen2014-08-271-7/+8
| | | | | | | | | | | | | | | | | | | to declaration. * fhandler_tty.cc (fhandler_pty_slave::fch_open_handles): Add bool parameter "chown". Only request WRITE_OWNER access when opening pty synchronization objects if "chown" is set. (fhandler_pty_slave::fchmod): Call fch_open_handles with new bool parameter set to false. (fhandler_pty_slave::fchown): Call fch_open_handles with new bool parameter set to true. * kernel32.cc (CreateFileMappingW): Fix default standard rights for file mappings from READ_CONTROL to STANDARD_RIGHTS_REQUIRED to allow changing the DACL (fixes "access denied" error in pinfo::set_acl). * fhandler_disk_file.cc (fhandler_base::fstat_helper): Change debug output to print mode bits in octal. * security.cc (alloc_sd): Ditto. (set_file_attribute): Ditto.
* * fhandler.h (fhandler_pty_master::~fhandler_pty_master): Delete.Christopher Faylor2013-12-171-9/+0
| | | | * fhandler_tty.cc (fhandler_pty_master::~fhandler_pty_master): Ditto.
* * external.cc (fillout_pinfo): If start_time is 0, wait a while beforeChristopher Faylor2013-10-241-0/+2
| | | | | | | | | | returning the pinfo structure. * fhandler.cc (fhandler_base::open_setup): Convert from inline. * fhandler.h (fhandler_base::open_setup): Declare. * fhandler_console.cc (fhandler_console::open_setup): Always call fhandler_base::open_setup. * fhandler_tty.cc (fhandler_pty_slave::open_setup): Ditto. (fhandler_pty_master::open_setup): Ditto.
* * fhandler.h (fhandler_base::cleanup): Mark as extern rather than inline.Christopher Faylor2013-10-221-0/+2
| | | | | | * fhandler_base.cc (fhandler_base::cleanup): Define. * fhandler_tty.cc (fhandler_pty_slave::cleanup): Call fhandler_base::cleanup. (fhandler_pty_master::cleanup): Ditto.
* * fhandler_tty.cc: Revert accidental checkin.Christopher Faylor2013-07-311-4/+1
| | | | * update-copyright: Ditto.
* cygwin directory changes:Christopher Faylor2013-07-261-1/+4
| | | | | | | | | | | | | * environ.cc (tty_is_gone): Delete. (known): Delete tty, add wincmdln. * globals.cc: Reorganize list of environment bools, remove explicit = false for slight load time optimization. (wincmdln): New global. * spawn.cc (child_info_spawn::worker): Honor wincmdln. doc directory changes: * new-features.sgml (ov-new1.7.23): Add new section. Mention wincmdln. * cygwinenv.xml: Mention wincmdln.
* revert accidentally checked in filesChristopher Faylor2013-06-081-4/+1
|
* * cygwait.cc (cygwait): Remove lock around sig retrieval since this code isChristopher Faylor2013-06-081-1/+4
| | | | | | essentially guarded by thread-specific signal_arrived. * exceptions.cc (_cygtls::handle_SIGCONT): Simplify. Eliminate lock/unlock since code is guarded by signal_arrived.
* * fhandler_tty.cc (fhandler_pty_common::__acquire_output_mutex): Never wait anChristopher Faylor2013-05-081-1/+3
| | | | | | INFINITE amount of time. Instead default to 1/10 second. (fhandler_pty_slave::open): Just default to INFINITE wait rather than (now) waiting longer than previously.
* Throughout, (mainly in fhandler*) fix remaining gcc 4.7 mismatchYaakov Selkowitz2013-05-011-4/+4
| | | | | | | | | 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-58/+56
|
* * DevNotes: Add entry cgf-000022.Christopher Faylor2013-01-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | * cygtls.h (_cygtls::func): Define as a sa_sigaction style function. * exceptions.cc (sig_handle_tty_stop): Ditto. (_cygtls::interrupt_setup): Fix coercion to accommodate 'func' change. (ctrl_c_handler): Use tty kill_pgrp to send a signal. (sigpacket::process): Don't process sigflush here. (_cygtls::call_signal_handler): Reorganize to avoid a race. Always call sa_sigaction style function. * fhandler_termios.cc (is_flush_sig): Define new function. (tty_min::kill_pgrp): Handle tty flush when signal detected. (fhandler_termios::bg_check): Be slightly more paranoid about checking for valid tty. (fhandler_termios::sigflush): Don't flush unless tty owner. * fhandler_tty.cc (fhandler_pty_slave::ioctl): Use tty kill_pgrp to send signal. (fhandler_pty_master::ioctl): Ditto. * signal.cc (killsys): Delete definition. * sigproc.h (killsys): Delete declaration. * include/cygwin/signal.h (siginfo_t): Simplify union/struct nesting slightly. Implement mechanism to allow cygwin data passing.
* Throughout, change __attribute__ ((regparm (N))) to just __regN. Throughout,Christopher Faylor2013-01-211-3/+3
| | | | | | | | | | | | | | | | | | | (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.
* * fhandler_registry.cc: Drop Mingw.org considerations.Corinna Vinschen2012-11-261-4/+0
| | | | | | | | | | | * fhandler_serial.cc: Ditto. * fhandler_socket.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * net.cc: Ditto. * ntdll.h: Ditto. * sched.cc: Ditto. * sec_helper.cc: Ditto.
* * fhandler_termios.cc (fhandler_termios::line_edit): Don't do special characterChristopher Faylor2012-11-081-1/+1
| | | | | | handling when stopped by CTRL-S. * fhandler_tty.cc (bytes_available): Add arguments to debug_only_printf call. * sigproc.cc (proc_subproc): Simplify some if logic.
* * fhandler_tty.cc (fhandler_pty_slave::write): Fix potential exit from loopChristopher Faylor2012-10-151-1/+2
| | | | | with write mutex held. Delete redundant mutex release. Clear tty error once we've grabbed it.
* * fhandler_tty.cc (fhandler_pty_slave::write): DWORD -> BOOL.Christopher Faylor2012-10-151-1/+1
|
* * fhandler_termios.cc (fhandler_termios::line_edit): Don't manipulateChristopher Faylor2012-10-121-4/+8
| | | | | | | | | output_mutex on CTRL-S/CTRL-Q to avoid a deadlock. * fhandler_tty.cc (fhandler_pty_slave::write): Loop when output_stopped is detected before acquiring output_mutex. Acquire output_mutex in the loop for each write. * tty.h: Remove some obsolete defines. (tty_min::output_stopped): Make 'bool'.
* whitespace cleanupChristopher Faylor2012-08-161-1/+1
|
* Rename cancelable_wait -> cygwait throughout.Christopher Faylor2012-08-151-1/+1
| | | | | * DevNotes: Add entry cgf-000015. * cygwait.h (cygwait): Don't allow an optional PLARGE_INTERGER argument.
* * cygwait.cc (cancelable_wait): Add some debugging-only output.Christopher Faylor2012-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | * exceptions.cc (sig_handle_tty_stop): Make sure that incyg is cleared when exiting if we have no parent process. Only wait for signal_arrived. (sigpacket::process): Make continue_now a bool. Delay sending signal_arrived until the end. Make code more defensive to avoid calling signal handler when stopped. Only set signal_arrived when stopped. * sigproc.cc (sig_hold): Rename from sigCONT. Make static. (sig_send): Accommodate sigCONT -> sig_hold rename. (wait_sig): Ditto. * sigproc.h (sigCONT): Delete declaration. * fhandler_console.cc (fhandler_console::write): Use new '%0c' facility to print characters. Change to paranoid to avoid excessive strace output. * fhandler_tty.cc (fhandler_pty_master::accept_input): Make frequent strace printf "paranoid" to help cut down on strace output size. * signal.cc (sigsuspend): Add standard syscall strace output. (sigpause): Ditto. (pause): Ditto. * cygtls.h (_cygtls::reset_signal_arrived): New function.
* * DevNotes: Add entry cgf-000013.Christopher Faylor2012-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * cygserver_ipc.h (ipc_set_proc_info): Use _cygtls::ipc_set_proc_info to set per-thread signal arrived value. * cygthread.cc (cygthread::detach): Use per-thread signal_arrived via set_thread_waiting. * fork.cc (_cygtls::fixup_after_fork): Clear signal_arrived. (_cygtls::remove): Close any signal_arrived handle when thread exists. (_cygtls::find_tls): Remove unneeded function. * cygtls.h: Update copyright. (class _cygtls): Reorganize to help avoid rebuilding newlib when structure changes. (_cygtls::event): Delete. (_cygtls::threadkill): Ditto. (_cygtls::signal_waiting): Declare new bool. (_cygtls::find_tls): Delete declaration. (_cygtls::set_threadkill): Ditto. (_cygtls::reset_threadkill): Ditto. (_cygtls::set_signal_arrived): Declare new function. (class set_thread_waiting): Declare new class. * cygwait.cc (cw_nowait_storage): Define. (cygwait): Set per-thread signal_arrived via set_thread_waiting. Don't special-case _main_tls. * cygwait.h (cw_nowait): Define. (cw_infinite): Ditto. (cygwait): Redefine pathological wait-only case. * dcrt0.cc (dll_crt0_0): Remove call to now-defunct events_init(). (dll_crt0_1): Remove call to now-defunct create_signal_arrived(). * exceptions.cc: Reflect set_signal_mask() argument reordering throughout. Remove signal mask synchronization throughout. (events_init): Delete definition. (mask_sync): Delete now-unneeded mask synchronization. (set_signal_mask): Reverse order of arguments to "standard" to, from layout. Rename "newmask" argument to "setmask". Remove debugging. (sig_handle_tty_stop): Use cancelable_wait rather than WFMO. (_cygtls::interrupt_setup): Don't treat "threadkill" events specially. Conditionally set signal_arrived depending on whether the thread has created it or not. (sigpacket::process): Reorganize to reflect thread-specific sending of signals which is more in line with the way it was actually supposed to work. * fhandler_socket.cc (get_inet_addr): Use cancelable_wait rather than IsEventSignalled to avoid potential race. (fhandler_socket::wait_for_events): Set signal_arrived event using set_thread_waiting(). (fhandler_socket::close): Use cygwait for the case of just waiting 10 ms for a signal. * fhandler_tape.cc (fhandler_dev_tape::_lock): Use cancelable_wait rather than WFMO. Redo switch/case tests accordingly. * fhandler_termios.cc (fhandler_termios::bg_check): Use cygwait for case of just waiting 0 ms for a potential signal. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Use cancelable_wait rather than WFSO. * fhandler_windows.cc (fhandler_windows::read): Set per-thread signal_arrived via set_thread_waiting(). * flock.cc (lf_setlock): Ditto. * select.cc (pselect): Ditto. Set per-thread signal_arrived using set_thread_waiting(). * gendef: Don't special case handling of _cygtls::sig for threads. * gentls_offsets: Use #pragma once in tlsoffsets.h. * ntdll.h: Use #pragma once. * poll.cc: Reflect set_signal_mask() argument reordering. * posix_ipc.cc (ipc_mutex_lock): Use cancelable_wait rather than WFMO. (ipc_cond_timedwait): Set perl-thread signal arrived using set_thread_waiting(). * security.h: Use #pragma once. * signal.cc (abort): Reflect set_signal_mask() argument reordering. (clock_nanosleep): Ditto. Change call to cancelable_wait to properly specify handling of cancel and interrupt. (sigwaitinfo): Remove handling of per-thread event in favor of per-thread signal_arrived. Use cancelable_wait rather than WFSO. * sigproc.cc (signal_arrived): Delete definition. (create_signal_arrived): Ditto. * sigproc.h (signal_arrived): Delete declaration. (set_signal_mask): Avoid defining as a "C" function. Don't conditionally declare. (create_signal_arrived): Delete declaration. * syscalls.cc (rename): Use cygwait() rather than WFSO. * thread.h (fast_mutex::lock): Use cw_infinite rather than LARGE_NULL. * wait.cc (wait4): Ditto. * thread.cc (pthread_mutex::lock): Ditto. (pthread::join): Ditto. (semaphore::_wait): Ditto. (pthread_kill): Remove set_threadkill() accommodation. * tlsoffsets.h: Regenerate.
* * fhandler_registry.cc (RegOpenUserClassesRoot): Only define whenCorinna Vinschen2012-07-061-0/+2
| | | | | | | | | | | | | | | | | | building against w32api headers. (RegOpenCurrentUser): Ditto. * fhandler_tty.cc (GetNamedPipeClientProcessId): Ditto. * ntdll.h (enum _PROCESSINFOCLASS): Add ProcessImageFileName. (RtlInitAnsiString): Declare. (RtlUnicodeStringToAnsiSize): Declare. * sched.cc (GetForegroundWindow): Ditto. * sec_helper.cc (SECURITY_NT_NON_UNIQUE): Define as SECURITY_NT_NON_UNIQUE_RID when building against w32api headers. (cygsid::get_sid): Use SECURITY_NT_NON_UNIQUE rather than SECURITY_NT_NON_UNIQUE_RID. (__sec_user): Use PISECURITY_DESCRIPTOR rather than PSECURITY_DESCRIPTOR to allow valid pointer arithmetic. (_recycler_sd): Ditto. (_everyone_sd): Ditto.
* * fhandler_tty.cc (fhandler_pty_slave::read): Remove duplicate assignment toChristopher Faylor2012-07-041-1/+0
| | | | bytes_in_pipe found by Clang.
* Revert errneous checkin.Christopher Faylor2012-06-191-1/+1
| | | | Check in actual change associated with ChangeLog.
* * cygwait.cc (cancelable_wait): Mimic old cygwait behavior more closely wrtChristopher Faylor2012-06-191-1/+1
| | | | | | | | handling of call_signal_handler. * cygwait.h (WAIT_CANCELED): Move here and redefine. (WAIT_SIGNALED): Ditto. * thread.h (WAIT_CANCELED): Delete. (WAIT_SIGNALED): Ditto.
* Add '#include "cygwait.h"' throughout, where appropriate.Christopher Faylor2012-06-171-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* * DevNotes: Add entry cgf-000008.Christopher Faylor2012-05-161-7/+10
| | | | | * fhandler_tty.cc (bytes_available): Simplify by returning the number of bytes available in the message unless that is zero.
* * DevNotes: Add entry cgf-000002.Christopher Faylor2012-05-041-2/+6
| | | | | | * fhandler_tty.cc (bytes_available): Revert to previous Oct-2011 behavior where a dummy buffer is used to determine how many bytes will be read. (fhandler_pty_master::ioctl): Correct coercion in assignment.
* * fhandler.h (fhandler_pty_common::bytes_available): Declare new function.Christopher Faylor2012-04-051-65/+68
| | | | | | | | | | | | | | | (fhandler_pty_master::flush_to_slave): Ditto. * fhandler_tty.cc (bytes_available): Define new function. (fhandler_pty_common::bytes_available): Ditto. (handler_pty_master::flush_to_slave): Ditto. (fhandler_pty_master::process_slave_output): Call flush_to_slave () here. Use bytes_available () rather than PeekNamedPipe. Cleanup sloppy logic. (fhandler_pty_slave::read): Use bytes_available () rather than PeekNamedPipe. (fhandler_pty_slave::ioctl): Ditto. (fhandler_pty_master::ioctl): Ditto. (fhandler_pty_master::cleanup): Remove ancient #if 0. * select.cc (peek_pipe): Call flush_to_slave whenever we're checking for a pty master.
* * Throughout, replace usage of w32api's min with MIN from sys/param.h.Corinna Vinschen2012-03-081-2/+3
|
* * fhandler_console.cc (fhandler_console::dup): Only set ctty when we haven'tChristopher Faylor2012-03-031-1/+10
| | | | | | | | | specifically called setsid. * fhandler_tty.cc (fhandler_pty_slave::dup): Ditto. Also add comment documenting research into rxvt problem. * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Don't check specifically for myself->ctty == -1. Test for > 0 as that is the correct test. (fhandler_termios::sigflush): Ditto.
* * cygheap.cc (init_cygheap::init_installation_root): Convert functionCorinna Vinschen2012-02-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.