Commit Graph

301 Commits

Author SHA1 Message Date
Corinna Vinschen bf0f4baf95 Revert "Debug printfs."
This reverts commit 9f82de59a0.

Revert accidental push
2016-03-20 21:59:43 +01:00
John Hood 9f82de59a0 Debug printfs.
* fhandler.cc (fhandler_base::get_readahead): Add debug code.
	* fhandler_console.cc (fhandler_console::read): Add debug code.
	* select.cc (pselect): Add debug code.
	(peek_console): Add debug code.
2016-03-20 15:26:31 +01:00
John Hood b92b47b7bc Move get_nonascii_key into fhandler_console.
* fhandler.h (fhandler_console): Move get_nonascii_key() from
	select.c into this class.
	* select.cc (peek_console): Move get_nonascii_key() into
	fhandler_console class.
2016-03-20 14:14:27 +01:00
Peter Foley 922e21a3ea Remove dead code from fhandler_console.
This if is unconditionally false, so remove it.

winsup/cygwin/fhandler_console.cc: In member function 'bool dev_console::fillin(HANDLE)':
winsup/cygwin/fhandler_console.cc:740:22: error: self-comparison always evaluates to false [-Werror=tautological-compare]
       if (b.dwSize.Y != b.dwSize.Y || b.dwSize.X != b.dwSize.X)
           ~~~~~~~~~~~^~~~~~~~~~~~~
winsup/cygwin/fhandler_console.cc:740:50: error: self-comparison always evaluates to false [-Werror=tautological-compare]
       if (b.dwSize.Y != b.dwSize.Y || b.dwSize.X != b.dwSize.X)
                                       ~~~~~~~~~~~^~~~~~~~~~~~~

winsup/cygwin/ChangeLog
* fhandle_console.cc (fillin): remove dead code

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 11:54:49 +01:00
Thomas Wolff 734656818a Make requested console reports work
cf https://cygwin.com/ml/cygwin-patches/2012-q3/msg00019.html

This enables the following ESC sequences:
ESC[c sends primary device attributes
ESC[>c sends secondary device attributes
ESC[6n sends cursor position report

    * fhandler.h (class dev_console): Add console read-ahead buffer.
    (class fhandler_console): Add peek function for it (for select).
    * fhandler_console.cc (fhandler_console::setup): Init buffer.
    (fhandler_console::read): Check console read-aheader buffer.
    (fhandler_console::char_command): Put responses to terminal
    requests (device status and cursor position reports) into
    common console buffer (shared between CONOUT/CONIN)
    instead of fhandler buffer (separated).
    * select.cc (peek_console): Check console read-ahead buffer.
2016-03-16 10:25:34 +01:00
Corinna Vinschen ac39f7b4e8 Drop sys_cp_wcstombs and save two arguments per call
* strfuncs.cc (sys_cp_wcstombs): Delete and move functionality into
        sys_wcstombs.
        * wchar.h (sys_cp_wcstombs): Drop declaration.
        * fhandler_console.cc (dev_console::con_to_str): Call sys_wcstombs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-18 12:42:40 +01:00
Christopher Faylor fb1565af68 * signal.cc (sigprocmask): Fix strace output to include "how".
* fhandler_console.cc (dev_console::save_restore): Only current dwEnd line
rather than the one after that.
2014-05-09 14:28:48 +00:00
Christopher Faylor 6e06243942 * DevNotes: Add entry cgf-000026.
* fhandler.h (fhandler_console::save_top): Save top of screen coordinates.
* fhandler_console.cc (dev::save_restore): Record top of screen coordinates.
Clear entire buffer when restoring saved buffer and try to position the cursor
on the save relative place on the screen.
2014-04-26 17:38:22 +00:00
Christopher Faylor 5c66535df9 * fhandler.h (dev_console::b): Redefine as CONSOLE_SCREEN_BUFFER_INFO for use
with older OS.
* fhandler_console.cc (dev_console::fillin): Ditto for
GetConsoleScreenBufferInfo.
2014-03-10 18:18:56 +00:00
Christopher Faylor ebfec24391 * fhandler_console.cc (dev_console::save_restore): Save entire line of current
cursor position.
2014-03-10 17:33:17 +00:00
Christopher Faylor cda5aac102 * fhandler_console.cc (fhandler_console::save_restore): Save only until last
written row and, because of this, don't bother trying to restore the screen
buffer size.  Set cursor position after refilling buffer.
(fhandler_console::write): Use absolute paths when saving/restoring cursor
position or suffer odd problems after a saved screen is restored.
2014-03-10 03:15:39 +00:00
Christopher Faylor dc5694dc88 * fhandler.h (fhandler_console::dwBufferSize): Delete.
(fhandler_console::dwCursorPosition): Ditto.
(fhandler_console::wAttributes): Ditto.
(fhandler_console::b): New field encompassing previously disparate screen
buffer info.
(fhandler_console::save_bufsize): Rename from savebufsiz
(fhandler_console::save_buf): Rename sfrom savebuf.
(fhandler_console::save_cursor): New field.
(fhandler_console::save_restore): New function.
(fhandler_console::con): Rename from dev_state.
(fhandler_console::focus_aware): Accommodate name change.
* fhandler_console.cc: Use 'b' field of dev_console throughout instead of
disparate names.  Accommodate dev_state -> con rename.
(dev_state:save_restore): New function.  Attempt to save the entire screen
buffer rather than just the visible part.  Clear the buffer when saving, like
Linux.
(fhandler_console::char_command): Use con.save_restore() for Save/restore
screen sequence.
2014-03-09 22:49:56 +00:00
Christopher Faylor e8036b41ab * fhandler_console.cc (fhandler_console::char_command): Properly use calculated
value rather than directly using dev_state.args[0].
2014-03-09 18:46:30 +00:00
Christopher Faylor 8a1a15ffd2 * fhandler.h (fhandler_console::scroll_buffer_screen): New function.
* fhandler_console.cc (fhandler_console::scroll_buffer_screen): New function.
(fhandler_console::char_command): Use scroll_buffer_screen as appropriate.
(dev_console::scroll_buffer): Remove if 0'ed block.
2014-02-26 03:58:37 +00:00
Christopher Faylor 7cb7f645d5 * dev_console::scroll_buffer): Reinstate clipping region. 2014-02-23 03:42:02 +00:00
Christopher Faylor f1d9e96c44 * fhandler.h (dev_console::is_fullscreen): Delete.
(dev_console::scroll_window): Return bool indicating success.
(dev_console::scroll_screen): New function.
(dev_console::clear_screen): New function.
(fhandler_console::clear_screen): Make __reg3.
(fhandler_console::cursor_set): Ditto.
(fhandler_console::cursor_get): Ditto.
(fhandler_console::cursor_rel): Ditto.
* fhandler_console.cc (dev_console::scroll_buffer): Adapt from
fhandler_console.
(fhandler_console::scroll_buffer): Use dev_console function.
(dev_console::is_fullscreen): Delete.
(dev_console::scroll_window): Return true if we cleared the screen.
Shrink/grow buffer first before scrolling to ensure that there is sufficient
space after scrolling.
(fhandler_console::clear_screen): Make reg3, use dev_console function.
(dev_console::clear_screen): New function adapted from fhandler_console.
(fhandler_console::cursor_set): Make __reg3.
(fhandler_console::cursor_rel): Ditto.
(fhandler_console::cursor_get): Ditto.
(fhandler_console::write): Fix "reverse index".
2014-02-23 03:38:52 +00:00
Christopher Faylor df2764ef93 * DevNotes: Add entry cgf-000024.
* fhandler.h (dev_console::state): Remove trailing underscore.
(dev_console::args): Ditto.
(dev_console::nargs): Ditto.
(dev_console::info): Eliminate subclass.
(dev_console::dwEnd): New field.
(dev_console::scroll_window): New function.
(dev_console::is_fullscreen): Ditto.
(dev_console::fillin): Rename from fillin_info.
(fhandler_console::scroll_buffer): Rename from scroll_screen.
* fhandler_console.cc: Throughout s/dev_state\.info/dev_state/g.  Accommodate
other name changes.
(dev_console::fillin): Accommodate rename.  Notice max x/y written to.  Forgo
memset if GetConsoleScreenBufferInfo fails.
(fhandler_console::scroll_buffer): Accommodate rename.  Don't treat y
coordinate of zero as top of screen.
(dev_console::is_fullscreen): New function.
(dev_console::scroll_window): Ditto.
(fhandler_console::clear_screen): Just scroll the screen when clearing the
screen in a state where the screen buffer is bigger than the screen.
(fhandler_console::char_command): Try harder to get 'S' and 'T' working in the
presence of a screen buffer.  Use temporary 'n' variable rather than
dev_state.args[0].  Use GNU ?: shortcut method.
2014-02-16 01:48:25 +00:00
Christopher Faylor 63b1a850b3 * fhandler.h (cltype): Add cl_buf_beg, cl_buf_end.
* fhandler_console.cc (dev_console::console_attrs::set_cl_x): Honor buffer
locations.
(dev_console::console_attrs::set_cl_y): Ditto.
(fhandler_console::write): On reset, use absolute positioning to go to
beginning of buffer.  Clear entire buffer.
2014-01-31 04:23:22 +00:00
Christopher Faylor 36383c6f6e * fhandler.h: Update copyright.
(cltype): New enum.
(dev_console::console_attrs): Define struct name.
(dev_console::console_attrs::set_cl_x): New function.
(dev_console::console_attrs::set_cl_y): New function.
(fhandler_console::clear_screen): Redefine input params.
* fhandler_console.cc: Update copyright.  Throughout, reflect change in
arguments to fhandler_console::clear_screeen.
(fhandler_console::mouse_aware): Simplify logic slightly.
(fhandler_console::scroll_screen): Remove hopefully obsolete win95 code.
(dev_console::console_attrs::set_cl_x): New function.
(dev_console::console_attrs::set_cl_y): New function.
(fhandler_console::clear_screen): Redefine input params.  Calculate position
based on enum value.
(region_split): Change arguments.  Simplify.
(ReadConsoleOutputWrapper): Remove coord argument since we now always use 0, 0.
Send extra arguments to region_split.
2014-01-04 23:58:32 +00:00
Christopher Faylor 7b52fd6713 * fhandler_console.cc (region_split): New function.
(delta): Ditto.
(ReadConsoleOutputWrapper): Ditto.
(fhandler_console::char_command): Use ReadConsoleOutputWrapper to avoid OOM
condition from ReadConsoleOutputW.  Add more debugging.
2013-12-31 22:19:07 +00:00
Corinna Vinschen d2a88d9792 Throughout, drop unnecessary explicit includes of windows header files
included by default.
	* winlean.h: Add long comment to explain why we have to define certain
	symbols.
	(_NORMALIZE_): Define.
	(_WINNLS_): Drop definition and subsequent undef.
	(_WINNETWK_): Ditto.
	(_WINSVC_): Ditto.

2013-11-23  Eric Blake  <eblake@redhat.com>
2013-11-24 12:13:36 +00:00
Christopher Faylor 4ae84b2251 * external.cc (fillout_pinfo): If start_time is 0, wait a while before
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.
2013-10-24 15:26:21 +00:00
Yaakov Selkowitz 1f36328e7f Throughout, (mainly in fhandler*) fix remaining gcc 4.7 mismatch
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.
2013-05-01 01:20:37 +00:00
Corinna Vinschen 61522196c7 * Merge in cygwin-64bit-branch. 2013-04-23 09:44:36 +00:00
Christopher Faylor bc837d22f3 Throughout, update copyrights to reflect dates which correspond to main-branch
checkins.  Regularize copyright format.
2013-01-21 04:38:31 +00:00
Corinna Vinschen 09707415eb * fhandler.h (class dev_console): Flag for expanded control sequence.
* fhandler_console.cc (char_command): Supporting cursor style modes.
2013-01-11 11:04:50 +00:00
Christopher Faylor 46f5dd5958 whitespace cleanup 2012-08-16 23:34:45 +00:00
Christopher Faylor d239805457 * cygwait.cc (cancelable_wait): Add some debugging-only output.
* 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.
2012-07-30 03:44:40 +00:00
Christopher Faylor 4ae6378382 Add '#include "cygwait.h"' throughout, where appropriate.
* 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-06-17 20:50:24 +00:00
Corinna Vinschen 8ee7527dc2 * fhandler.h (class dev_console): Add member ext_mouse_mode5.
* fhandler_console.cc (fhandler_console::read): Implement extended
	mouse mode 1005 (xterm, mintty).
	Fix actual mouse reporting for large coordinates.
2012-04-25 07:25:00 +00:00
Corinna Vinschen d581bbfa8e * fhandler_console.cc (ALT_PRESSED): Define earlier, never undefine.
(CTRL_PRESSED): Ditto.
	(fhandler_console::read): Simplify expressions testing for pressed ALT
	or CTRL modifier keys.
	(get_nonascii_key): Ditto.
2012-04-24 14:39:22 +00:00
Corinna Vinschen c9df1b2729 * fhandler.h (class dev_console): Add members ext_mouse_mode6 and
ext_mouse_mode15.
	* fhandler_console.cc (fhandler_console::read): Implement extended
	mouse modes 1015 (urxvt, mintty, xterm) and 1006 (xterm).  Recognize,
	but don't implement extended mouse mode 1005 (xterm, mintty).
	Support mouse coordinates greater than 222 (each axis).  Fix formatting.
	(fhandler_console::char_command): Initialize enhanced mouse reporting
	modes.
2012-04-24 14:29:37 +00:00
Christopher Faylor aba77cbe8f wincap.h: Rename assitant to assistant throughout. wincap.cc: Ditto.
* devices.in (exists_console): Use fhandler_console::exists () rather than raw
test.
* devices.cc: Regenerate.
* fhandler.h (fhandler_console::exists): Define new function.
* fhandler_console.cc (fhandler_console::need_invisible): Use
fhandler_console::exists () rather than raw test.
* spawn.cc: Rename assitant to assistant throughout.
(child_info_spawn::worker): Simplify test for when to start a non-Cygwin
process in its own process group.  Just do it whenever we start a non-Cygwin
process.
2012-04-15 17:51:22 +00:00
Christopher Faylor 3bfa9d984b * devices.in (exists_console): Allow /dev/con{sole,in,out} to be referenced
they exist.
* devices.cc: Regenerate.
* fhandler_console.cc (fhandler_console::set_unit): Ditto.
2012-04-13 02:30:51 +00:00
Christopher Faylor 881beea81d * dtable.cc (dtable::fixup_close): Define new function.
(dtable::fixup_after_exec): Use fixup_close() and detect when it was not
possible to open an inherited file handle.
(dtable::fixup_after_fork): Defensively close any file handles which were not,
for some reason, inheritable.
* dtable.h: Make #pragma once.
(dtable::fixup_close): Declare new function.
* fhandler_console.cc (fhandler_console::set_unit): Set I/O handles to NULL
when this function fails.
2012-04-01 22:28:39 +00:00
Christopher Faylor d46ed263af * fhandler_console.cc (fhandler_console::set_unit): Don't succeed unless we are
opening a console actually associated with this process.
2012-03-29 17:34:55 +00:00
Christopher Faylor 6c95669d23 * dtable.cc (fh_alloc): Treat pc.dev as unsigned.
* fhandler_console.cc (fhandler_console::set_unit): Use lock always to avoid
races between competing cygwin processes running on the console.
2012-03-10 17:51:33 +00:00
Corinna Vinschen 75543537a1 * Throughout, replace usage of w32api's min with MIN from sys/param.h. 2012-03-08 09:36:11 +00:00
Christopher Faylor bd7c945953 * fhandler_console.cc (fhandler_console::dup): Only set ctty when we haven't
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.
2012-03-03 21:35:30 +00:00
Corinna Vinschen 109bc58303 * fhandler_console.cc (fhandler_console::input_tcsetattr): Revert
prevois patch.
	(fhandler_console::open_setup): Install Ctrl-C handler here, if this
	console is the controlling tty and the process hasn't been started by
	a Cygwin process.
2012-03-02 11:56:06 +00:00
Corinna Vinschen bfeed1643e * fhandler_console.cc (fhandler_console::input_tcsetattr): Set the
state of the Ctrl-C handler depending on the setting of
	ENABLE_PROCESSED_INPUT.
2012-03-02 10:17:16 +00:00
Corinna Vinschen 8895d962d5 * cygheap.cc (init_cygheap::init_installation_root): Convert function
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.
2012-02-14 11:27:43 +00:00
Christopher Faylor 3e9c8f2e81 * cygheap.cc (init_cygheap::manage_console_count): Delete.
* cygheap.h (init_cygheap::manage_console_count): Ditto.
(init_cygheap::console_count): Ditto.
* fhandler.h (fhandler_console::has_a): Ditto.
(fhandler_console::free_console): Declare new function.
* fhandler_console.cc (fhandler_console::free_console): Define new function.
(fhandler_console::open_setup): Delete call to manage_console_count.
(fhandler_console::close): Ditto.  Replace with call to free_console().
* fhandler_tty.cc (fhandler_pty_slave::open): Delete call to
manage_console_count.
(fhandler_pty_slave::cleanup): Ditto.
(fhandler_pty_slave::close): Call fhandler_console::free_console() if this is
our controlling tty.
* pinfo.cc (_pinfo::set_ctty): Skip function if tty in question == our ctty.
Delete call to manage_console_count.
* syscalls.cc (close_all_files): Avoid locking and avoid setting errno when
iterating over fds.
2012-02-07 16:54:14 +00:00
Christopher Faylor 1b23b30b29 Clean up whitespace. 2011-12-17 23:39:47 +00:00
Christopher Faylor 8cb58e8566 * cygthread.h (cygthread::name): Very minor formatting tweak.
* 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-13 04:11:48 +00:00
Christopher Faylor 57af01797e Rename cygWFMO to cygwait throughout and use the magic of polymorphism to "wait
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-09 16:02:56 +00:00
Christopher Faylor 8f937028d9 * exceptions.cc (exception::handle): Drop abbreviation for "exception" since I
never remember what it stands for.
(sig_handle_tty_stop): Remove obsolete call to sig_handle_tty_stop.
(_cygtls::call_signal_handler): Rework to grab signal information from
_main_tls if none is set for _my_tls.  Try harder to keep thread locked.
(reset_signal_arrived): Delete.
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use new cygWFMO call
to wait for an event + standard cygwin stuff.  Modify debug output to
acccomodate new function.
* fhandler_console.cc (fhandler_console::read): Replace WaitForMultipleObjects
with cygWFMO.
* fhandler_socket.cc (get_inet_addr): Add comment.
* gendef (_sigdelayed): Remove call to reset_signal_arrived.
* sigproc.cc (_cygtls::signal_exit): Don't close my_readsig here unless we're
in the signal thread.
(create_signal_arrived): Create signal_arrived as auto-reset so that only one
thread is woken when a signal arrives.
* sigproc.h (cygWFMO): New function.
(reset_signal_arrived): Delete declaration.
2011-12-04 17:58:24 +00:00
Christopher Faylor b9aa81491f Throughout, remove extra space after function name from debugging output.
Throughout, change syscalls to report on return values using new %R format
option.
* smallprint.cc (__small_vsprintf): Add parsing for %R to report on return
values and possible errno from syscalls.
* errno.cc (errmap): Add PRIVILEGE_NOT_HELD.
* fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread use
shorter name to reduce debuggging output.
* select.cc (start_thread_pipe): Ditto.
(start_thread_serial): Ditto.
(start_thread_socket): Ditto.
(start_thread_mailslot): Ditto.
* sigproc.cc (talktome): Ditto.
2011-12-03 21:43:27 +00:00
Christopher Faylor 56a1971526 Throughout use "have_execed" macro rather than "hExeced" global handle.
Throughout rename _PROC_* to _CH_*.
* child_info.h: Include "pinfo.h".
(child_info_types): Rename _PROC_* -> _CH_* to avoid confusion with similarly
named constants.
(_PROC_*): Delete unneeded aliases.
(PROC_*): Ditto.
(CURR_CHILD_INFO_MAGIC): Ditto.
(cchildren): Define using "pinfo_minimal".
(child_info::set_saw_ctrl_c): Move to
(child_info_spawn::set_saw_ctrl_c): Here.
(child_info_spawn::lock): New field.
(child_info_spawn::hExeced): Ditto.
(child_info_spawn::ev): Ditto.
(child_info_spawn::~child_info_spawn): Move to sigproc.cc.
(child_info_spawn::child_info_spawn): Ditto.
(child_info_spawn::cleanup): Declare new function.
(child_info_spawn::set_saw_ctrl_c): Move to this class.  Set flag only when
execed and return true when we have set the flag.
(child_info_spawn::child_info_spawn::signal_myself_exited): New function.
(child_info_spawn::wait_for_myself): Ditto.
(child_info_spawn::has_execed_cygwin): Ditto.
(child_info_spawn::has_execed): Ditto.  Replaces "hExeced" test.
(child_info_spawn::operator HANDLE&): New operator.
(child_info_spawn::worker): Define old "spawn_guts" as class member.
(ch_spawn): Declare.
(have_execed): Define.
(have_execed_cygwin): Ditto.
* cygheap.h: Update comment.
* dcrt0.cc (get_cygwin_startup_info): Use _CH_* enums.
(child_info_spawn::handle_spawn): Ditto.
(dll_crt0_0): Ditto.
(multiple_cygwin_problem): Ditto.
* exceptions.cc (chExeced): Delete obsolete declaration.
(ctrl_c_handler): Reference set_saw_ctrl_c via new ch_spawn global.
* globals.cc (hExeced): Delete.
* pinfo.cc (pinfo::thisproc): Refer to cygheap as ::cygheap for consistency in
handle naming when -DDEBUGGING.
(pinfo::init): Accommodate case where myself.h is known but h0 is passed in.
(pinfo::pinfo): New constructor for setting up a pinfo passed in by previous
exec'or.
(pinfo::proc_waiter): Don't handle subprocess if we're in the process of
exiting due to an exec of a cygwin process.  Don't close rd_proc_pipe here.
Close it when we actually are finished with the process.  Use new
ch_spawn.signal_myself_exited function to let exec stub know that subprocess
has exited.
(pinfo::wait): Clarify debugging output.
(pinfo::release): Use "close_h" to close all handles to avoid races.
(winpids::add): Assume that elements of the array do not need to be zeroed and
are properly initialized or suffer problems on pinfo::release.  Don't close
hProcess since release does that now.
* pinfo.h: Update comment.
(pinfo_minimal): Move some elements from pinfo here so that child_info_spawn
can use them.
(pinfo): Inherit from pinfo_minimal.
(pinfo::pinfo): Modify to accommodate new pinfo_minimal.
(pinfo::allow_remove): New function.
* sigproc.cc (proc_subproc): Use boolean values for true/false.  Implement
PROC_EXEC_CLEANUP.
(proc_terminate): Set ppid = 1 since the procs list will only be iterated when
the process has not execed.  Don't do any cleanup here since it is now handled
in pinfo::release.
(sigproc_init): Initialize sync_proc_subproc earlier.
(child_info::child_info): Assume that all important fields are properly
initialized and avoid memset().
(child_info_spawn::child_info_spawn): Specifically test for execing and then
set up appropriate fields in the struct.
(child_info_spawn::cleanup): Define new function.
(child_info_spawn::record_children): Specifically test for being execed here.
Fill in pinfo_minimal part of children array.
(child_info_spawn::reattach_children): Use constructor to duplicate information
for previous exec'or.  Add more debugging output.
(remove_proc): Force deletion of thread when exiting due to exec.  Rely on
pinfo::cleanup in release.
* sigproc.h (PROC_EXEC_CLEANUP): New enum.
(PROC_DETACHED_CHILD): Delete.
* spawn.cc (chExeced): Delete.
(child_info_spawn::worker): Rename from spawn_guts.  Use elements of
child_info_spawn throughout rather than ch.whatever.  Use ::cygheap to refer to
global rather than element of child_info.  Use wait_for_myself() rather than
waitpid().  Call child_info_spawn::cleanup on function return.
(spawnve): Reflect movement of spawn_guts functionality into
child_info_spawn::worker.
* syscalls.cc (popen): Ditto.
* winsup.h (spawn_guts): Delete declaration.
2011-11-14 01:29:49 +00:00
Christopher Faylor 6ae28c2263 * dtable.cc (dtable::delete_archetype): Improve debugging output.
(dtable::init_std_file_from_handle): Close console handle early, before
initialization.  Build up openflags for passing to open_setup, just to be safe.
(last_tty_dev): New variable.
(fh_last_tty_dev): New macro.
(fh_alloc): Try again to keep track of previously opened tty, this time by just
saving the device and using that to potentially open an archetype.  Avoid
setting the "/dev/tty" name if the creation of the fhandler failed.
(build_fh_pc): Remove unused second argument.  Reorganize how and where the
name is set.  Set last_tty_dev as appropriate.  Avoid a NULL dereference in a
debug printf.
* dtable.h (build_fh_pc): Reflect removal of second parameter.
* fhandler.cc (fhandler_base::reset): Use new '<<' operator to copy pc since it
preserves any potentially previously set name.
(fhandler_base::set_name): Ditto.
* fhandler.h (fhandler_*::clone): Throughout use ccalloc to allocate new
fhandler, primarily to make sure that pc field is properly zeroed.
(fhandler_termios::last): Eliminate.
(fhandler_termios): Remove setting of last.
(fhandler_base::~fhandler_termios): Ditto.
* fhandler_console.cc (fhandler_console::open): Don't make decisions about
opening close-on-exec handles here since it makes no sense for archetypes.
(fhandler_console::init): Assume that input handle has already been opened.
* fhandler_termios.cc (fhandler_termios::last): Delete.
* path.h (path_conv::eq_worker): New function.  Move bulk of operator = here.
(operator <<): New function.
(operator =): Use eq_worker to perform old functionality.
2011-10-22 16:26:30 +00:00