Commit Graph

369 Commits

Author SHA1 Message Date
Christopher Faylor f0b04035b1 * dcrt0.cc (dll_crt0_0): Move _main_tls initialization here.
(__dll_crt0): Only initialize _main_tls if it changes.
* fhandler_console.cc (fhandler_console::write): Fix debugging output.
2010-10-02 19:08:21 +00:00
Christopher Faylor 6c6eb02b33 * cygthread.h (cygthread::cygthread): Reorganize slightly.
* dcrt0.cc (dll_crt0_0): Move sigproc initialization later to ensure everything
we need has been set up.
(dll_crt0_1): Streamline some logic slightly.
* sigproc.cc (no_signals_available): Add back dropped test for macro parameter.
* fhandler_console.cc (fhandler_console::write): Show a little bit of what's
being written to the console in debugging output.
2010-09-12 15:49:30 +00:00
Corinna Vinschen 0250709234 * fhandler.h (class dev_console): Add backspace_keycode member.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Initialize
	backspace_keycode with CERASE.
	(fhandler_console::read): Return dev_state->backspace_keycode if the
	backspace key is pressed.
	(fhandler_console::char_command): Implement DECBKM escape sequence.
2010-04-11 19:11:17 +00:00
Christopher Faylor 1d6adee8ed * fhandler_console.cc (fhandler_console::read): Default to sending CERASE
character if termios VERASE field is zero.
(fhandler_console::fixup_after_fork_exec): Avoid a spurious debug message.
2010-04-10 18:05:52 +00:00
Corinna Vinschen ca8eb333c9 2010-03-30 Thomas Wolff <towo@towo.net>
* fhandler.h (class dev_console): Drop vt100_graphics_mode_active.
	Add flags vt100_graphics_mode_G0, vt100_graphics_mode_G1 and
	iso_2022_G1.
	* fhandler_console.cc: Throughout, tune VT100 graphics mode switching
	to follow ISO 2022 strictly.
2010-03-30 16:17:34 +00:00
Christopher Faylor bd3b3783f8 * shared_info.h (open_shared): Create function wrapper for common use case.
(open_shared): Change fifth argument to a pointer rather than a reference.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Eliminate use of dummy
variable and call open_shared with constant.
* fhandler_process.cc (format_process_mounts): Ditto.
* pinfo.cc (pinfo::init): Pass pointer to shloc.
* shared.cc (shared_mem_inited): New variable.
(open_shared): Crate function wrapper for common use case.
(open_shared): Accommodate change to fifth argument to a pointer.
(shared_info::initialize): Remove spinlock test.  Simplify function.  Move
get_session_parent_dir call back here.
(memory_init): Protect global shared settings with shared_mem_inited spinlock.
Move get_session_parent_dir call to shared_info::initialize.
2010-03-09 21:26:55 +00:00
Corinna Vinschen e70fdfb99f * cygwin.din (dup3): Export.
(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.
2010-01-14 18:46:02 +00:00
Christopher Faylor 37520977df * fhandler_console.cc (handler_console::read): Use the tty's VERASE character
as the backspace keycode.
2009-12-25 17:38:46 +00:00
Corinna Vinschen b2d6e5dfd3 * fhandler_console.cc (get_nonascii_key): Generate ESC prefix
for Alt modifier generically for function keys and keypad keys.
	Distinguish Normal, Ctrl, Shift, Ctrl-Shift rather
	than Normal, Ctrl, Shift, Alt, so that in combination with generic
	Alt handling all 8 combinations of these modifiers are distinguished.
	(keytable): Add escape sequences for remaining modified
	function keys as a compatible extension using rxvt escape codes.
	Also distinguish keypad keys modified with Ctrl, Shift, Ctrl-Shift
	using xterm-style modifier coding.
2009-12-21 10:11:27 +00:00
Corinna Vinschen 57a2873a5d * fhandler_console.cc (__vt100_conv): Minor formatting change. 2009-12-19 15:40:31 +00:00
Corinna Vinschen 8fd4bd2bf1 * fhandler_console.cc (write_console): Check for VT100
graphics mode and transform wide characters in ASCII small
	letter range to corresponding graphics.
	(__vt100_conv): Table to transform small ASCII letters to line
	drawing graphics for use in VT100 graphics mode.
	(write_normal): Check for SO/SI control characters to
	enable/disable VT100 graphics mode.
	(base_chars): Enable SO/SI control characters for detection.
	(write): Check for ESC ( 0 / ESC ( B escape sequences to
	enable/disable VT100 graphics mode. Also detect ">" while
	parsing ESC [ sequences to distinguish specific requests.
	(char_command): Distinguish Secondary from Primary Device Attribute
	request to report more details about cygwin console terminal version.
	* fhandler.h (vt100_graphics_mode_active): New flag to indicate mode.
	(saw_greater_than_sign): New parse flag for ESC [ > sequences.
	(gotparen, gotrparen): New state values to parse ESC ( / ) sequences.

	* fhandler_console.cc (read): Allow combined Alt-AltGr modifiers
	to also produce an ESC prefix like a plain Alt modifier, e.g. to make
	Alt-@ work on a keyboard where @ is AltGr-q.
2009-12-19 15:37:10 +00:00
Corinna Vinschen beeae48288 * fhandler_console.cc (read): Detect and handle mouse wheel scrolling
events (for completion of mouse reporting mode 1000) and mouse
	movement events (for additional mouse reporting modes 1002 and 1003).
	Use mouse_aware() as a guard and only condition for mouse
	reporting in order to enforce consistence of read() and select().
	Add focus reports (for additional focus reporting mode 1004).
	(mouse_aware): Enable detection of additional mouse events for select().
	Tune function to precisely match actual reporting criteria.
	Move adjustment of mouse position (by window scroll offset)
	here to avoid duplicate code.
	(char_command): Initialization of enhanced mouse reporting modes.
	Initialization of focus reporting mode.
	* fhandler.h (use_mouse): Change flag (bool->int) to indicate
	additional mouse modes. Add flag to indicate focus reporting.
	(mouse_aware): Move enhanced function into fhandler_console.cc.
	* select.cc (peek_console): Use modified mouse_aware() for more
	general detection of mouse events. Also check for focus reports.
2009-12-16 14:56:10 +00:00
Corinna Vinschen f04f6d49fa * fhandler_console.cc (char_command): Fix code to select dim mode
to 2 rather than 9.  Add entries for mode 22 (normal, not bold)
	28 (visible, not invisible), 25 (not blinking).
2009-12-15 12:46:40 +00:00
Corinna Vinschen 03c48ee2e0 * fhandler_console.cc (fhandler_console::read): Revert change from
2009-11-09.
2009-11-10 20:02:20 +00:00
Corinna Vinschen ed66791aba * fhandler_console.cc (fhandler_console::read): Restrict generating
META key sequences to singlebyte input chars.
2009-11-09 15:38:36 +00:00
Corinna Vinschen 4180b64df4 * fhandler_console.cc (beep): Move up to avoid forward declaration.
(fhandler_console::read): Just beep on characters invalid in current
	charset.  Add comment.
2009-09-30 09:23:45 +00:00
Corinna Vinschen 587b75f7bd * fhandler.h (class dev_console): Constify charset parameter of
str_to_con.
	* fhandler_console.cc (dev_console::con_to_str): Simplify.  Always
	default to the current internal locale.
	(dev_console::get_console_cp): Always use codepage 437 for alternate
	charset.
	(dev_console::str_to_con): Constify charset parameter.
	(fhandler_console::write_normal): Always use codepage 437 for alternate
	charset.  Otherwise always default to the current internal locale.
	Replace ASCII SO with ASCII CAN.
	* strfuncs.cc: Tweka comments according to below changes.
	(sys_cp_wcstombs): Constify charset parameter.  Convert all wchar_t
	values in the Unicode private use area U+F0xx to the singlebyte
	counterpart.  Drop special handling creating ASCII SO sequence from
	U+DCxx value.  Rearrange for performance.  Replace ASCII SO with
	ASCII CAN.
	(sys_cp_mbstowcs): Constify charset parameter.  Replace ASCII SO with
	ASCII CAN.  Drop special case for U+DCxx ASCII SO sequences.  Always
	create a replacement from the Unicode private use area U+F0xx for
	invalid byte values in a multibyte sequence.  Do the same for wchar_t
	values from the U+F0xx range to make them roundtrip safe.
	* wchar.h (sys_cp_wcstombs): Constify charset parameter.
	(sys_cp_mbstowcs): Ditto.
2009-09-28 12:10:32 +00:00
Christopher Faylor 78d959ce6f * fhandler_console.cc (create_invisible_console_workaround): Fix size of cmd in
the way originally intended.
2009-08-10 15:25:58 +00:00
Corinna Vinschen 264ae244af * fhandler_console.cc (create_invisible_console_workaround): Fix
size of cmd to take spaces into account.
2009-08-10 08:54:51 +00:00
Corinna Vinschen 6359951b47 * fhandler_console.cc (set_console_title): Set buffer size to
TITLESIZE + 1.  Call sys_mbstowcs with correct destination length.
2009-07-25 08:27:10 +00:00
Christopher Faylor 43c23d4b82 * sigproc.h (wait_for_sigthread): Eliminate parameter.
* sigproc.cc (wait_for_sigthread): Ditto.  Don't synchronize with wait_sig
after receiving an event that it is ready to go.
(init_sig_pipe): New function.
(wait_sig): Call init_sig_pipe to create pipes for communicating signals to
this process.  Don't send sigCONT signal when initializing.
* fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change.
* fhandler.h (fhandler_*::write): Make ssize_t/__stdcall.
(fhandler_*::write_overlapped): Ditto.
(fhandler_*::raw_write): Ditto.
(fhandler_*::readv): Ditto.
(fhandler_*::writev): Ditto.
(fhandler_*::raw_read): Make __stdcall.
* fhandler: Accommodate changes to read/write functions throughout.
* fhandler_clipboard.cc: Ditto.
* fhandler_console.cc: Ditto.
* fhandler_dsp.cc: Ditto.
* fhandler_fifo.cc: Ditto.
* fhandler_mailslot.cc: Ditto.
* fhandler_mem.cc: Ditto.
* fhandler_mem.cc: Ditto.
* fhandler_random.cc: Ditto.
* fhandler_tape.cc: Ditto.
* fhandler_tty.cc: Ditto.
* fhandler_virtual.cc: Ditto.
* fhandler_windows.cc: Ditto.
* fhandler_zero.cc: Ditto.
* syscalls.cc (readv): Use ssize_t as temp variable.
* fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will
never be treated as < 0.
(fhandler_base::wait_overlapped): Minimize calls to GetLastError.  Remove
duplicate debugging test.  Fix error return.
* fhandler.h (fhandler_fifo::fifo_name): Declare new function.
(fhandler_fifo::close): Ditto.
(fhandler_fifo::dup): Ditto.
(fhandler_fifo::close_on_exec): Ditto.
* fhandler.cc (fhandler_fifo::fifo_name): Define new function.
(FIFO_BUF_SIZE): New define.
(cnp): Ditto.
(fhandler_fifo::open): Rework.  Use cnp to open named pipe.  Always open write
side as a client.  Open dummy client when writing and can't connect.
(wait): Rework.  Implement fifo_wait_for_next_client.  Handle signals during
connect better.  Add new fifo_wait_for_server code which polls
(sigh) waiting for server.
(fhandler_fifo::raw_read): Handle transition states when one client closes and
another is available.
(fhandler_fifo::close): Define.
(fhandler_fifo::dup): Ditto.
(fhandler_fifo::close_on_exec): Ditto.
2009-07-24 20:54:33 +00:00
Christopher Faylor 5ea3e685eb * fhandler_console.cc: Change workstation -> windows station throughout. 2009-07-05 16:49:56 +00:00
Christopher Faylor 01d8a2dfd6 * autoload.cc (SetParent): Add new import.
* fhandler.h (fhandler_console::create_invisible_console): Declare new
function.
(create_invisible_console_workaround): Ditto.
* fhandler_console.cc (fhandler_console::create_invisible_console): Define new
function.
(create_invisible_console_workaround): Ditto.  Add too much code to deal with
broken Windows 7.  Use a helper app to start an invisible console window.
(fhandler_console::need_invisible): Reorganize to use helper functions to
create invisible console.
* spawn.cc (spawn_guts): Avoid zeroing already zeroed fields in si.
2009-07-04 23:51:10 +00:00
Christopher Faylor 3c4f2024a1 * dcrt0.cc (jit_debug): New global.
(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.
2009-07-03 18:05:51 +00:00
Corinna Vinschen a4175657bf * autoload.cc: Fix typo in comment.
(ShowWindowAsync): Define.
	(AttachConsole): Define.
	* fhandler_console.cc (fhandler_console::need_invisible): Add band-aid
	for Windows 7 AllocConsole bug.
2009-07-03 10:50:51 +00:00
Corinna Vinschen 7774a4b029 * fhandler_console.cc (set_console_title): Convert title string to
wchar_t and call SetConsoleTitleW.
2009-06-04 14:59:47 +00:00
Corinna Vinschen f17f20c139 * fhandler_console.cc (fhandler_console::read): Allow Ctrl-Space to
emit a NUL byte.
2009-06-04 09:57:34 +00:00
Corinna Vinschen c48a1e46bf * fhandler_console.cc (fhandler_console::read): Convert Alt-Backspace
to \033\177 or to \377 dependent on the setting of dev_state->metabit.
2009-06-03 11:07:38 +00:00
Christopher Faylor bfa7707bce * fhandler_console.cc (fhandler_console::read): Convert backspace key to DEL. 2009-05-30 05:51:41 +00:00
Corinna Vinschen 6f401eccfb * cygheap.cc (cygheap_init): Set Cygwin default locale values.
* cygheap.h (struct cygheap_locale): New structure.
	(struct user_heap_info): Add cygheap_locale member locale.
	* dcrt0.cc (dll_crt0_1): Revert to calling _setlocale_r so that only
	the applications locale is reverted to "C".
	* environ.cc (environ_init): Remove unused got_lc variable.
	* fhandler.h (class dev_console): Remove now unsed locale variables.
	* fhandler_console.cc (fhandler_console::get_tty_stuff): Remove
	setting dev_console's locale members.
	(dev_console::con_to_str): Use internal locale settings.  Default to
	__ascii_wctomb if charset is "ASCII".
	(fhandler_console::write_normal): Ditto.
	* strfuncs.cc (__ascii_wctomb): Drop declaration.
	(__db_wctomb): Use fixed value 2 instead of not
	necessarily matching MB_CUR_MAX.
	(__eucjp_wctomb): Use 3 instead of MB_CUR_MAX.
	(sys_cp_wcstombs): Remove special case for "C" locale.
	(sys_wcstombs): Implement here.  Use internal locale data stored on
	cygheap.
	(sys_cp_mbstowcs): Remove special case for "C" locale.
	(sys_mbstowcs): Implement here.  Use internal locale data stored on
	cygheap.
	* syscalls.cc (internal_setlocale): New function to set cygheap locale
	data and to reset CWD posix path.
	(setlocale): Just call internal_setlocale from here if necessary.
	* wchar.h (__ascii_wctomb): Declare.
	(sys_wcstombs): Don't define inline, just declare.
	(sys_mbstowcs): Ditto.
2009-05-14 19:49:37 +00:00
Christopher Faylor 6f5b891b7b * fhandler_console.cc (fhandler_console::ioctl): Properly treat TIOCLINUX
argument as a char.
* fhandler_tty.cc (fhandler_tty_slave::ioctl): Use coercion to properly set
char value.
2009-05-06 17:16:33 +00:00
Christopher Faylor 56a4d31a7f * fhandler_console.cc (fhandler_console::write_console): Eliminate unneeded
debugging output.
(fhandler_console::write_normal): Eliminate unneeded __seterrno.
2009-05-04 04:43:50 +00:00
Christopher Faylor b65ec404a7 * fhandler.h (fhandler_console::MAX_WRITE_CHARS): Declare.
(fhandler_console::write_replacement_char): Declare as inline.
(fhandler_console::write_console): Declare new function.
* fhandler_console.cc (fhandler_console::MAX_WRITE_CHARS): Define.
(handler_console::write_console): Define.
(fhandler_console::write_replacement_char): Define as inline.
(fhandler_console::write_normal): Use write_console when writing buffers of
unknown length.
2009-05-04 03:51:16 +00:00
Corinna Vinschen 62755474e5 * fhandler.h (class dev_console): Add members con_mbtowc, con_wctomb,
and con_charset.
	(dev_console::str_to_con): Take mbtowc function pointer and charset
	as additional parameters.
	* fhandler_console.cc (fhandler_console::get_tty_stuff): Initialize
	aforementioned new members.  Explain why.
	(dev_console::con_to_str): Remove useless comment.  Call new
	sys_cp_wcstombs function rather than sys_wcstombs.
	(dev_console::str_to_con): Take mbtowc function pointer and charset
	as additional parameters.  Call sys_cp_mbstowcs accordingly.
	(fhandler_console::write_normal): Only initialize f_mbtowc and charset
	once.  Accommodate changed str_to_con.
	* strfuncs.cc (sys_cp_wcstombs): Renamed from sys_wcstombs.  Take
	wctomb function pointer and charset as parameters.  Use throughout.
	(sys_cp_mbstowcs): Take wctomb function pointer and charset as
	parameters instead of codepage.  Remove matching local variables and
	their initialization.
	* wchar.h (ENCODING_LEN): Define as in newlib.
	(__mbtowc): Use mbtowc_p typedef for declaration.
	(wctomb_f): New type.
	(wctomb_p): New type.
	(__wctomb): Declare.
	(__utf8_wctomb): Use wctomb_f typedef for declaration.
	(sys_cp_wcstombs): Move declaration from winsup.h here.
	(sys_wcstombs): Ditto.
	(sys_wcstombs_alloc): Ditto.
	(sys_cp_mbstowcs): Ditto.
	(sys_mbstowcs): Ditto.
	(sys_mbstowcs_alloc): Ditto.
	* winsup.h: Move declaration of sys_FOO functions to wchar.h.  Include
	wchar.h instead.
2009-04-07 12:13:37 +00:00
Corinna Vinschen 5354e13fe6 * environ.cc (environ_init): Break from locale loop after first hit.
* fhandler_console.cc (fhandler_console::write_normal): Print a SO
	sequence using always valid Unicode chars.
2009-03-25 12:29:04 +00:00
Corinna Vinschen 161211d186 * ctype.cc (_CTYPE_DATA_0_127): Add _B class to TAB character.
(__ctype_default): New character class array for default ASCII
	character set.
	(__ctype_iso): New array of character class array for ISO charsets.
	(__ctype_cp): Ditto for singlebyte Windows codepages.
	(tolower): Implement as distinct function to support any singlebyte
	charset.
	(toupper): Ditto.
	(__set_ctype): New function to copy singlebyte character classes
	corresponding to current charset to ctype_b array.
	Align copyright text to upstream.
	* dcrt0.cc (dll_crt0_1): Reset current locale to "C" per POSIX.
	* environ.cc (set_file_api_mode): Remove.
	(codepage_init): Remove.
	(parse_thing): Remove "codepage" setting.
	(environ_init): Set locale according to environment settings, or
	to current codepage, before converting environment to multibyte.
	* fhandler.h (fhandler_console::write_replacement_char): Drop argument.
	* fhandler_console.cc (dev_console::str_to_con): Call sys_cp_mbstowcs
	rather than MultiByteToWideChar.
	(fhandler_console::write_replacement_char): Always print a funny
	half filled square if a character isn't in the current charset.
	(fhandler_console::write_normal): Convert to using __mbtowc
	rather than next_char.
	* fork.cc (frok::child): Drop call to set_file_api_mode.
	* globals.cc (enum codepage_type) Remove.
	(current_codepage): Remove.
	* miscfuncs.cc (cygwin_wcslwr): Unused, dangerous.  Remove.
	(cygwin_wcsupr): Ditto.
	(is_cp_multibyte): Remove.
	(next_char): Remove.
	* miscfuncs.h (is_cp_multibyte): Drop declaration.
	(next_char): Ditto.
	* strfuncs.cc (get_cp): Remove.
	(__db_wctomb): New function to implement _wctomb_r functionality for
	doublebyte charsets using WideCharToMultiByte.
	(__sjis_wctomb): New function to replace unusable newlib function.
	(__jis_wctomb): Ditto.
	(__eucjp_wctomb): Ditto.
	(__gbk_wctomb): New function.
	(__kr_wctomb): Ditto.
	(__big5_wctomb): Ditto.
	(__db_mbtowc): New function to implement _mbtowc_r functionality for
	doublebyte charsets using MultiByteToWideChar.
	(__sjis_mbtowc): New function to replace unusable newlib function.
	(__jis_mbtowc): Ditto.
	(__eucjp_mbtowc): Ditto.
	(__gbk_mbtowc): New function.
	(__kr_mbtowc): New function
	(__big5_mbtowc): New function
	(__set_charset_from_codepage): New function.
	(sys_wcstombs): Reimplement, basically using same wide char to multibyte
	conversion as newlib's application level functions.  Plus extras.
	Add lengthy comment to explain.  Change return type to size_t.
	(sys_wcstombs_alloc): Just use sys_wcstombs.  Change return type to
	size_t.
	(sys_cp_mbstowcs): Replace sys_mbstowcs, take additional codepage
	argument.  Explain why.  Change return type to size_t.
	(sys_mbstowcs_alloc): Just use sys_mbstowcs.  Change return type to
	size_t.
	* wchar.h: Declare internal functions implemented in strfuncs.cc.
	(wcscasecmp): Remove.
	(wcsncasecmp): Remove.
	(wcslwr): Remove.
	(wcsupr): Remove.
	* winsup.h (codepage_init): Remove declaration.
	(get_cp): Ditto.
	(sys_wcstombs): Align declaration to new implementation.
	(sys_wcstombs_alloc): Ditto.
	(sys_cp_mbstowcs): Add declaration.
	(sys_mbstowcs): Define as inline function.
	(sys_mbstowcs_alloc): Align declaration to new implementation.
	(set_file_api_mode): Remove declaration.
	* include/ctype.h (isblank): Redefine to use _B character class.
	(toupper): Remove ASCII-only definition.
	(tolower): Ditto.
2009-03-24 12:18:34 +00:00
Christopher Faylor 7b9e380f03 * cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error.
* 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.
2008-09-11 04:34:24 +00:00
Corinna Vinschen 9cdaf8733f * fhandler.h (set_console_state_for_spawn): Drop declaration.
* fhandler_console.cc (set_console_state_for_spawn): Remove.
	(fhandler_console::open): Set console state last.  Don't set
	ENABLE_PROCESSED_INPUT flag.
	* spawn.cc (spawn_guts): Drop call to set_console_state_for_spawn.
2008-06-12 15:57:23 +00:00
Christopher Faylor a7e0bc7bbe remove obsolete comment 2008-06-12 14:55:08 +00:00
Christopher Faylor b13e6864f5 Remove unneeded header files from source files throughout. 2008-04-07 18:45:59 +00:00
Christopher Faylor ade47a3430 Add miscfuncs.h to files as needed throughout.
* mount.cc: New file.
* path.cc: Move mount-specific stuff into mount.cc.  Move common stuff into
miscfuncs.cc.  Remove unneeded includes.
* miscfuncs.cc: Move some common path functions here.
* miscfuncs.h: New file.
* winsup.h: Move miscelleneous functions to miscfuncs.h.
* dcrt0.cc: Remove unneeded includes.
* Makefile.in (DLL_OFILES): Add mount.o.
* include/cygwin/config.h: Fix a minor typo.
2008-04-07 16:15:45 +00:00
Corinna Vinschen a7d2cc16e2 * Fix copyright dates. 2008-04-01 13:22:47 +00:00
Corinna Vinschen 949c0ec28c * fhandler.h (class fhandler_console): Add write_buf as pointer to
temporary buffer space.
	* fhandler_console.cc (CONVERT_LIMIT): Define as NT_MAX_PATH.  Add
	comment.
	(fhandler_console::write_normal): Use write_buf throughout.
	(fhandler_console::write): Use tmp_pathbuf to allocate write_buf.
2008-03-10 17:23:50 +00:00
Corinna Vinschen f37e220e86 * fhandler_console.cc (fhandler_console::write_normal): Don't print
chars marked as ERR chars.
2008-03-10 16:48:56 +00:00
Corinna Vinschen 3e148838af * fhandler.h (dev_console::con_to_str): Declare returning DWORD.
* fhandler_console.cc (dev_console::con_to_str): Return number of
	multibyte char bytes.
	(fhandler_console::read): Set nread to number of multibyte char bytes
	returned from con_to_str.
	(fhandler_console::write_normal): Reorder trunc buffer preocessing.
	Return after writing valid multibyte sequence out of trunc buffer.
	Change comments slightly.
2008-03-10 16:22:38 +00:00
Corinna Vinschen 752b16ce35 * Makefile.in (DLL_OFILES): Add tls_pbuf.o.
* autoload.cc (CreateDesktopW): Replace CreateDesktopA.
	(CreateWindowStationW): Replace CreateWindowStationA.
	(GetUserObjectInformationW): Replace GetUserObjectInformationA.
	* cygheap.h (cwdstuff::get): Assume default buffer size NT_MAX_PATH.
	* cygtls.cc (_cygtls::remove): Free temporary TLS path buffers.
	* cygtls.h (TP_NUM_C_BUFS): Define.
	(TP_NUM_W_BUFS): Define.
	(class tls_pathbuf): New class to store pointers to thread local
	temporary path buffers.
	(_local_storage::pathbufs): New member.
	* environ.cc (win_env::add_cache): Use temporary TLS path buffer instead
	of stack based buffer.
	(posify): Get temporary outenv buffer from calling function.
	(environ_init): Create temporary TLS path buffer for posify.
	(build_env): Create Windows environment block as WCHAR buffer.
	* environ.h (build_env): Change declaration accordingly.
	* external.cc (sync_winenv): Accommodate build_env change.
	* fhandler_console.cc (fhandler_console::need_invisible): Use
	GetUserObjectInformationW and CreateWindowStationW.
	* fhandler_process.cc (format_process_maps): Use temporary TLS path
	buffer instead of stack based buffer.
	* fork.cc (frok::parent): Convert to use CreateProcessW.
	* path.cc: Throughout use temporary TLS path buffers instead of stack
	based buffer.  Replace checks for CYG_MAX_PATH by checks for
	NT_MAX_PATH.
	(getfileattr): New function to replace GetFileAttributesA.
	(normalize_win32_path): Remove Win32 and NT long path prefixes.
	(getwd): Assume PATH_MAX + 1 buffer per SUSv3.
	* path.h (class path_conv): Set path buffer to size NT_MAX_PATH.
	(iswdrive): Define.
	* pinfo.cc (commune_process): Use temporary TLS path buffer instead of
	stack based buffer.
	* registry.cc (get_registry_hive_path): Ditto.
	(load_registry_hive): Ditto.
	* spawn.cc (spawn_guts): Convert to use CreateProcessW and
	CreateProcessAsUserW.
	(av::fixup): Open/close file using NtOpenFile/NtClose.
	* syscalls.cc (mknod_worker): Allow PATH_MAX file name.
	(mknod32): Ditto.
	(getusershell): Ditto.
	* tls_pbuf.cc: New file implementing tls_pathbuf and tmp_pathbuf
	methods.
	* tls_pbuf.h: New header for files using tmp_pathbuf.
	* tlsoffsets.h: Regenerate.
	* winsup.h (NT_MAX_PATH): Define as 32767 to avoid USHORT overflow.
2008-03-07 11:24:51 +00:00
Christopher Faylor 70300fdb1c Perform whitespace cleanup throughout.
* 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.
2008-02-15 17:53:11 +00:00
Corinna Vinschen 4b65f19045 * fhandler.h (fhandler_console::trunc_buf): Add to use as cache for
truncated multibyte characters on input.
	(fhandler_console::write_replacement_char): Declare new method.
	* fhandler_console.cc (CONVERT_LIMIT): Raise to 64K.
	(fhandler_console::fhandler_console): Initialize trunc_buf.
	(ERR): Define as independent value again.
	(fhandler_console::write_replacement_char): New method to print
	replacement chars.
	(fhandler_console::write_normal): Add handling for truncated multibyte
	sequences.  Call next_char instead of pathetic CharNextExA function.
	Don't change src, rather just work with found later on.
	* miscfuncs.cc (is_cp_multibyte): Move here from strfuncs.cc.
	Don't call Windows function, restrict to well-known ANSI/OEM codepages
	and UTF-8.
	(next_char): Call CharNextExA only for doublebyte codepages.
	Implement for UTF-8 here.
	* strfuncs.cc (is_cp_multibyte): Move to miscfuncs.cc.
	* winsup.h (next_char): Declare.
	* include/limits.h (MB_LEN_MAX): Set to maximum value of MB_CUR_MAX
	as defined by newlib for now.
2008-02-06 18:24:50 +00:00
Corinna Vinschen a7197550f3 * autoload.cc (CharToOemA): Remove.
(CharNextExA): Define.
	* environ.cc (codepage_init): Un-static.  Set active_codepage to
	active codepage.  Default to ansi regardless of buf pointer.
	* fhandler.h (dev_console::get_console_cp): New method.
	(dev_console::con_to_str): Change declaration according to new
	implementation.
	(dev_console::str_to_con): Ditto.
	* fhandler_console.cc (cp_convert): Remove.
	(dev_console::con_to_str): Redefine to take WCHAR as incoming console
	char.
	(dev_console::get_console_cp): Return correct codepage according to
	alternate_charset_active setting.
	(dev_console::str_to_con): Redefine to create WCHAR buffer for console
	output.
	(fhandler_console::read): Read console input as WCHARs.
	(base_chars): Fix typo in comment.
	(fhandler_console::char_command): Save and restore console output
	buffer using UNICODE functions.
	(fhandler_console::write_normal): Convert to write output in UNICODE.
	Use CharNextExA to recognize multibyte characters in input.  Workaround
	problem with UTF-8 and MultiByteToWideChar.  Simplify the loop for
	printing "normal" characters.
	* strfuncs.cc (active_codepage): New variable to store active codepage.
	(get_cp): Call codepage_init() if active_codepage is uninitialized.
	Just return active_codepage.
	(is_cp_multibyte): New function.
	* winsup.h (active_codepage): Declare.
	(codepage_init): Declare.
	(is_cp_multibyte): Declare.
2008-02-05 17:37:10 +00:00
Corinna Vinschen 1597484cb5 * dcrt0.cc (dll_crt0_1): Use GetCommandLineW and convert to current
codepage.
	* environ.cc (set_file_api_mode): Always set file api to ANSI if not
	using the OEM codepage.
	(codepage_init): Allow "utf8" codepage.
	* fhandler_clipboard.cc (set_clipboard): Convert clipbuf to void and
	cast as needed.  Always convert input to wide char and write
	CF_UNICODETEXT to clipboard.
	(fhandler_dev_clipboard::read): Read CF_UNICODETEXT from clipboard and
	convert to current codepage if CYGWIN_NATIVE format is not available.
	* fhandler_console.cc: Drop redundant undef.
	* smallprint.cc (__small_vsprintf): Convert PWCHAR and UNICODE_STRING
	to current codepage for printing.
	* strfuncs.cc: Use PWCHAR throughout.
	(get_cp): Return CP_UTF8 for utf8_cp codepage setting.
	(sys_wcstombs): Allow NULL target buffer.
	(sys_wcstombs_alloc): New function.
	(sys_mbstowcs_alloc): Ditto.
	* winsup.h (codepage_type): Add utf8_cp.
	(HEAP_NOTHEAP): Define.
	(sys_wcstombs_alloc): Declare.
	(sys_mbstowcs_alloc): Declare.
2008-01-31 20:26:01 +00:00
Christopher Faylor ee4388c420 Change many cygheap allocation routines to their *_abort analogs.
* cygheap.cc (cmalloc_abort): New function.
(crealloc_abort): Ditto.
(ccalloc_abort): Ditto.
2007-11-26 21:30:49 +00:00
Corinna Vinschen b5cb5c9e64 * fhandler_console.cc (fhandler_console::need_invisible): Drop
pty_needs_alloc_console check.
	* spawn.cc (spawn_guts): Ditto.
	(av::fixup): Remove setting iscui.
	* syscalls.cc (rename): Drop has_move_file_ex checks.  Remove 9x
	specific code.
	* wincap.cc: Remove has_move_file_ex and pty_needs_alloc_console
	throughout.
	* wincap.h: Ditto.
2007-02-23 12:01:52 +00:00
Corinna Vinschen 3af640487f * fhandler_console.cc (fhandler_console::read): Drop 9x specific
handling of AltGr key.
	* mmap.cc: Take NT for granted throughout.
	* wincap.cc: Remove map_view_of_file_ex_sucks, altgr_is_ctrl_alt,
	has_working_copy_on_write, share_mmaps_only_by_name,
	virtual_protect_works_on_shared_pages, has_mmap_alignment_bug and
	has_working_virtual_lock throughout.
	* wincap.h: Ditto.
2007-02-22 17:35:14 +00:00
Christopher Faylor 510a85cbf9 Remove extraneous whitespace.
* pinfo.cc (commune_process): Use default argument to lock_process.
* sigproc.cc: Update copyright.
* select.cc: Ditto.
2007-02-20 00:16:18 +00:00
Corinna Vinschen bf4071fad0 * fhandler_console.cc (set_color): Avoid (again) inappropriate
intensity interchanging that used to render reverse output unreadable
	when (non-reversed) text is bright.
	See http://sourceware.org/bugzilla/show_bug.cgi?id=514
2006-11-23 10:08:04 +00:00
Corinna Vinschen 6258d96af8 * fhandler.h (class dev_console): Add `metabit' indicating the
current meta key mode.
	* fhandler_console.cc (fhandler_console::read): Set the top bit of
	the character if metabit is true.
	* fhandler_console.cc (fhandler_console::ioctl): Implement
	KDGKBMETA and KDSKBMETA commands.
	* fhandler_tty.cc (process_ioctl): Support KDSKBMETA.
	(fhandler_tty_slave::ioctl): Send KDGKBMETA and KDSKBMETA to the
	master.
	* include/cygwin/kd.h: New file for the meta key mode.
	* include/sys/kd.h: New file.
2006-07-03 15:29:10 +00:00
Christopher Faylor 71d59a926f * dcrt0.cc (dll_crt0_0): Call tty_list::init_session here.
(dll_crt0_1): Reflect renaming from tty_init to tty::init_session.
(do_exit): Reflect moving of tty_terminate into tty_list.
* exceptions.cc (events_init): Move tty_mutex stuff elsewhere.
* fhandler_console.cc (set_console_title): Use lock_ttys class.
* fhandler_termios.cc (fhandler_termios::bg_check): Make debug output more
accurate.
* fhandler_tty.cc (fhandler_tty_slave::open): Reflect move of attach_tty into
tty_list class.  Don't attempt to grab master end of pty if master doesn't
exist.
(fhandler_pty_master::open): Reflect move of allocate_tty into tty_list class.
Use lock_ttys::release to release mutex.  Improve debugging output.
(fhandler_pty_master::setup): Remove if 0'ed block.  Fix argument to
SetNamedPipeHandleState.
* pinfo.cc (_pinfo::set_ctty): Lock ttys before setting sid/pgid.  Improve
debugging.  Add temporary debugging.
* tty.cc (tty_list::init_session): New function.
(tty::init_session): Rename from tty_init.  Reflect move of attach_tty to
tty_list class.
(tty::create_master): Rename from create_tty_master.
(tty_list::attach): Rename from attach_tty.  Reflect renaming of connect_tty to
connect.  Ditto for allocate_tty.
(tty_terminate): Delete.
(tty_list::terminate): Subsume tty_terminate.  Use lock_ttys rather than
manipulating mutex directly.
(tty_list::allocate): Rename from allocate_tty.  Use lock_ttys rather than
manipulating mutex directly.  Don't set sid here since linux apparently doesn't
do this.  Reflect move of create_tty_master into tty.
(lock_ttys::lock_ttys): Define new constructor.
(lock_ttys::release): New function.
* tty.h (tty::exists): Return false immediately if !master_pid.
(tty::set_master_closed): Define new function.
(tty::create_master): Ditto.
(tty::init_session): Ditto.
(tty_list::mutex): New field.
(tty_list::allocate): Define new function.
(tty_list::connect): Ditto.
(tty_list::attach): Ditto.
(tty_list::init_session): Ditto.
(lock_ttys): New class.
(tty_init): Delete declaration.
(tty_terminate): Ditto.
(attach_tty): Ditto.
(create_tty_master): Ditto.
2006-06-03 20:32:07 +00:00
Christopher Faylor 1160b21781 * fhandler_console.cc (fhandler_console::need_invisible): Allocate an invisible
window station when ctty != TTY_CONSOLE.
2006-05-19 00:32:36 +00:00
Christopher Faylor f09acf77de * tty.h (tty::hwnd): Move to tty_min.
(tty::gethwnd): Ditto.
(tty::sethwnd): Ditto.
(tty_min::hwnd): Receive variable from tty class.
(tty_min::gethwnd): Receive function from tty classs.
(tty_min::sethwnd): Ditto.
* dtable.cc (dtable::stdio_init): Only call init_console_handler when we
actually own the console.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Set tty's hwnd to
non-zero value.
* fhandler_termios.cc (fhandler_termios::tcsetpgrp): Semi-reinstate handling of
console when pgrp is set.
2006-04-21 18:53:05 +00:00
Christopher Faylor f12c262a43 * fhandler_console.cc (fhandler_console::fixup_after_fork_exec): Make error
message more explicit.
* pinfo.cc (_pinfo::commune_request): Don't lock process unless we're looking
for fifos.
2006-03-23 23:58:52 +00:00
Christopher Faylor 974f27a51a * cygheap.cc (init_cygheap::manage_console_count): Turn console control handler
on/off depending on whether we have allocated a console or not.
* dcrt0.cc (child_info_fork::fork_retry): Add more potential retry statuses.
(dll_crt0_0): Turn on/off console control depending on whether we have a
controlling tty or not.
* exceptions.cc (init_console_handler): Change BOOL to bool.
* fhandler_console.cc (fhandler_console::need_invisible): Cosmetic change.
* winsup.h (init_console_handler): Reflect argument type change.
* wincap.h (supports_setconsolectrlhandler_null): Remove duplicate capability
throughout.
* wincap.cc: Ditto.
2006-03-16 02:57:37 +00:00
Christopher Faylor 9287bcd534 * fhandler_console.cc (set_console_state_for_spawn): Fix to recognize ttys >=
0.
2006-01-12 05:17:12 +00:00
Christopher Faylor 750874d33d * fhandler.h (set_console_state_for_spawn): Whackamole the argument back to a
bool.
* spawn.cc (spawn_guts): Ditto, i.e., once again call
set_console_state_for_spawn with an indication of whether we're about to start
a cygwin process.
* fhandler_console.cc (set_console_state_for_spawn): Don't set the console
state if we know we're starting a cygwin process or if we're using a "real"
tty.
2006-01-12 05:03:15 +00:00
Christopher Faylor b5c8e33120 * fhandler_console.cc (fhandler_console::need_invisible): Remove duplicate
test.
2006-01-07 18:00:19 +00:00
Christopher Faylor 85c804ec4b * fhandler.h (set_console_state_for_spawn): Eliminate argument from
declaration.
* fhandler.cc (set_console_state_for_spawn): Eliminate argument from
definition.  Always check for invisible console.
(fhandler_console::need_invisible): Don't do anything if the windows station is
already not visible.
* spawn.cc (spawn_guts): Accommodate change of argument to
set_console_state_for_spawn.
2006-01-07 17:57:26 +00:00
Christopher Faylor 4cf4fd4d1c (fix ChangeLog and check in remaining files)
* sigproc.cc (sigproc_init): Move clearing of sync_startup here to lessen the
likelihood of trying to deal with non-cygwin threads in dll_entry.
* fhandler_console: Fix set_console_state_for_spawn comment.
2006-01-05 16:26:22 +00:00
Christopher Faylor 4c3faa85ce * fhandler_console.cc (fhandler_console::need_invisible): Only try to open
"CygwinInvisible" windows station if opening of default station fails.  Use
CloseWindowStation to close window station handle.
2006-01-05 03:58:19 +00:00
Christopher Faylor faec62caaf * fhandler_console.cc (fhandler_console::need_invisible): Open up the security
of the newly created windows station.
2006-01-05 00:49:17 +00:00
Christopher Faylor d58ca0b320 * fhandler_console.cc (beep): Use MB_OK which is documented as using the
default bell rather than -1 which seems to behave differently on different
versions of Windows.
2006-01-04 04:47:19 +00:00
Christopher Faylor 4c15746236 * fhandler_process.cc (fhandler_process::readdir): Add missing argument to
syscall_printf.
* fhandler_console.cc (fhandler_console::need_invisible): Use made-up name for
windows station rather than asking Windows to create one for us.
* spawn.cc (spawn_guts): Don't mess with console if we're detaching.
2006-01-04 03:43:55 +00:00
Christopher Faylor adcff8d159 * dir.cc (readdir_worker): Minor code cleanup.
* fhandler_console.cc (beep): Use a more Windows-generic wav file if the beep
is missing.  Use a more foolproof way to find out whether we should be
recreating the missing key.
* registry.h (reg_key::_disposition): New field.
(reg_key::created): New function.
* registry.cc (reg_key::reg_key): Set _disposition to zero by default.
(reg_key::build_key): Fill in _disposition field.
2006-01-03 17:44:26 +00:00
Christopher Faylor e76625eadb * fhandler_console.cc (beep): New function. Restores missing "Default Beep",
if necessary.
(fhandler_console::write_normal): Use beep().
2006-01-03 01:15:29 +00:00
Christopher Faylor 7a01aa546d * fhandler.h (set_console_state_for_spawn): Add an argument to the declaration.
* fhandler_console.cc (set_console_state_for_spawn): Ditto for the definition.
Only set invisible console for non-cygwin process.  Remove debugging leftover.
* spawn.cc (spawn_guts): Pass argument denoting whether this is a cygwin
process to set_console_state_for_spawn and only call this function when
exec'ing.
2005-12-19 19:04:14 +00:00
Christopher Faylor 65438ec635 * fhandler.h (fhandler_pipe::fixup_in_child): Declare new function.
(fhandler_console::invisible_console): Declare new variable.
(fhandler_console::need_invisible): Ditto.
(fhandler_console::has_a): Ditto.
* fhandler_console.cc (set_console_state_for_spawn): Eliminate return value.
Set up an invisible console if necessary prior to spawning.
(fhandler_console::invisible_console): Define.
* fhandler_tty.cc (fhandler_tty_slave::open): Use
fhandler_console::invisible_console to setup an invisible console.
* pipe.cc (fhandler_pipe::fixup_in_child): Define new function from
fixup_after_exec.
(fhandler_pipe::fixup_after_exec): Use fixup_in_child when appropriate.
(fhandler_pipe::fixup_after_fork): Ditto.
* spawn.cc (handle): Reorganize and modernize a little.
(spawn_guts): Rely on set_console_state_for_spawn to set the console into the
right state but don't create the process with "detached" flag if we have no
controlling tty since that confuses 'cmd'.
* dtable.cc (dtable::stdio_init): Don't set console as controlling terminal if
we have an invisible console.
* sigproc.cc (child_info::sync): Use correct name in ForceCloseHandle1.
2005-12-19 04:34:13 +00:00
Christopher Faylor 548d0080af * fhandler.h (fhandler_console::fixup_after_fork_exec): Define with additional
bool parameter.
(fhandler_console::fixup_after_exec): Accommodate fixup_after_fork_exec's
parameter.
(fhandler_console::fixup_after_fork): Ditto.
* fhandler_console.cc (fhandler_console::fixup_after_fork_exec): Avoid opening
new console only when close_on_exec AND execing.
2005-11-14 14:15:51 +00:00
Christopher Faylor 5a0826c3f8 * fhandler.h (fhandler_console::fixup_after_fork_exec): Declare new function.
(fhandler_console::fixup_after_fork): Use fixup_after_fork_exec.
(fhandler_console::fixup_after_exec): Ditto.
* fhandler_console.cc (fhandler_console::fixup_after_fork): Delete definition.
(fhandler_console::fixup_after_fork_exec): Rename from fixup_after_exec.
* pinfo.cc (_pinfo::set_ctty): Don't play with console count here.
* syscalls.cc (close_all_files): Don't close cygheap ctty if hExeced since the
child will be copying information from us.
(setsid): Use myctty() rather than raw ctty #.
2005-11-14 05:36:16 +00:00
Christopher Faylor 59297e0464 * cygheap.h (init_cygheap::manage_console_count): Declare new function.
(init_cygheap::console_count): Renamed from open_fhs.  Make private.
* cygheap.cc (init_cygheap::manage_console_count): Define new function.
* dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on
elements of fd even when they are about to be closed.
* fhandler.h (report_tty_counts): Remove open_fhs from debugging output.
* fhandler_console.cc (fhandler_console::open): Use manage_console_count rather
than manipulating count directly.
(fhandler_console::close): Ditto.
(fhandler_console::fixup_after_fork): Ditto.
(fhandler_console::fixup_after_exec): Ditto.  Don't close handles if
close_on_exec.
* fhandler_tty.cc (fhandler_tty_slave::open): Use manage_console_count() rather
than manipulating count directly.  Reflect change in arguments to
report_tty_counts().
(fhandler_tty_slave::close): Ditto for both.
(fhandler_tty_slave::dup): Ditto for both.
(fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #.
(fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to
report_tty_counts().
(fhandler_tty_master::init_console): Use manage_console_count() rather than
manipulating count directly.
* fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): Don't
perform any operations if close_on_exec.
* fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto.
* fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto.
* pinfo.h (_pinfo::_ctty): Declare new function.
(myctty): Declare new macro.
(__ctty): Declare new macro.
* pinfo.cc (_pinfo::_ctty): Define new function.
(_pinfo::set_ctty): Use manage_console_count() rather than manipulating count
directly.
* signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than raw ctty
#.
* syscalls.cc (setsid): Ditto.  Use manage_console_count() rather than
manipulating count directly.
2005-11-14 04:28:45 +00:00
Corinna Vinschen dcb091caaf Revert erroneous checkin. 2005-09-28 19:22:25 +00:00
Corinna Vinschen 1204c515fe * fhandler.h (class fhandler_dev_raw): Delete current_position and
eof_detected status flag.  Delete is_eom and is_eof methods.
	Move drive_size, bytes_per_sector, eom_detected status flag, as well
	as the methods read_file, write_file, raw_read and raw_write to ...
	(class fhandler_dev_floppy): ... here. Remove is_eom and is_eof
	methods.  Add dup method.
	* fhandler_floppy.cc (IS_EOM): New macro.
	(fhandler_dev_floppy::is_eom): Remove.
	(fhandler_dev_floppy::is_eof): Remove.
	(fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags.
	(fhandler_dev_floppy::get_drive_info): Only call EX functions on
	systems supporting them and stop suffering strange delays.
	(fhandler_dev_floppy::read_file): Move here, drop setting
	current_position.
	(fhandler_dev_floppy::write_file): Move here, drop setting
	current_position.
	(fhandler_dev_floppy::open): Rearrange comment.
	(fhandler_dev_floppy::dup): New method.
	(fhandler_dev_floppy::get_current_position): New inline method.  Use
	instead of former current_position were appropriate.
	(fhandler_dev_floppy::raw_read): Move here.  Drop EOF handling.
	(fhandler_dev_floppy::raw_write): Move here.  Drop EOF handling.
	(fhandler_dev_floppy::lseek): Remove useless conditions.  Convert
	sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call.
	(fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case
	to here.
	* fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove.
	(fhandler_dev_raw::is_eof): Remove.
	(fhandler_dev_raw::write_file): Remove.
	(fhandler_dev_raw::read_file): Remove.
	(fhandler_dev_raw::raw_read): Remove.
	(fhandler_dev_raw::raw_write): Remove.
	(fhandler_dev_raw::dup): Drop copying removed members.
	(fhandler_dev_raw::ioctl): Drop blocksize testing.
	* wincap.h: Implement has_disk_ex_ioctls throughout.
	* wincap.cc: Ditto.
	(wincap_vista): Preliminary wincaps for Windows Vista/Longhorn.
	(wincapc::init): Add Vista/Longhorn handling.
2005-09-28 19:02:53 +00:00
Christopher Faylor 67483cb2cd * dcrt0.cc (do_exit): Rely on sigproc_terminate to set exit_state
appropriately.
* pinfo.cc (pinfo::exit): Always call sigproc_terminate here.  Rely on
sigproc_terminate to signal signal thread to handle eventual process exit.
* sigproc.cc (no_signals_available): Change criteria for determining if this
process can handle signals to itself.
(my_sendsig): New variable.  Copy of my sendsig handle.
(proc_can_be_signalled): Don't send signals if exit code is set.
(sigproc_terminate): Use and set exit_state appropriately to determine when to
do anything.  Send __SIGEXIT to self to control process exit.
(sig_send): Use my_sendsig for sending signals.  Don't call
proc_can_be_signalled for myself since the criteria is now different for
sending signals to myself.
(wait_sig): Copy myself->sendsig to my_sendsig for future use.  Exit signal
loop when __SIGEXIT is received.  Wait for main thread to exit and use its exit
status to actually exit process.
* sigproc.h (__SIGEXIT): New enum.
* dcrt0.cc (alloc_stack): Eliminate superfluous "return;".
* debug.cc (add_handle): Ditto.
* devices.in (device::parse): Ditto.
* dtable.cc (dtable::vfork_parent_restore): Ditto.
(dtable::vfork_child_fixup): Ditto.
* environ.cc (parse_options): Ditto.
* errno.cc (seterrno_from_win_error): Ditto.
* exceptions.cc (sig_handle_tty_stop): Ditto.
(set_signal_mask): Ditto.
* fhandler.cc (fhandler_base::read): Ditto.
(fhandler_base::operator delete): Ditto.
(fhandler_base::seekdir): Ditto.
(fhandler_base::rewinddir): Ditto.
* fhandler_console.cc (fhandler_console::read): Ditto.
(fhandler_console::fixup_after_exec): Ditto.
* sigproc.cc (sigproc_init): Ditto.
(sigproc_terminate): Ditto.

* devices.cc: Regenerate.
2005-09-13 17:08:54 +00:00
Christopher Faylor 0c55f6ed60 Eliminate (void) cast on standalone function calls throughout. 2005-07-06 20:05:03 +00:00
Christopher Faylor 2f9ae2ed94 Change foo (void) to foo () for all c++ functions throughout. Remove all
fhandler_*::dump functions throughout.
* fhandler.h (fhandler_dev_mem::close): Remove pass-through function in favor
of virtual method.
(handler_dev_raw::close): Ditto.
(fhandler_dev_clipboard::fixup_after_exec): New method.
* fhandler_dev_mem.cc (fhandler_dev_mem::close): Eliminate pass through
* fhandler_dev_raw.cc (fhandler_dev_raw::close): Ditto.
* fhandler_clipboard.cc (fhandler_dev_clipboard::close): Don't go to extra
effort when execing.
(fhandler_dev_clipboard::fixup_after_exec): New function.
* fhandler_console.cc (fhandler_console::close): Don't do "extra stuff" when we
know we're execing.
* fhandler_disk_file.cc (fhandler_disk_file::close): Ditto.
* fhandler_dsp.cc (fhandler_dev_dsp::close): Ditto.
* fhandler_fifo.cc (fhandler_fifo.cc::close): Ditto.  function in favor of base
function.
* fhandler_random.cc (fhandler_dev_random::close): Ditto.
* fhandler_registry.cc (fhandler_registry::close): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::close): Ditto.
* fhandler_virtual.cc (fhandler_virtual::close): Ditto.
* pinfo.cc (proc_waiter): Remove unneeded hExeced declaration.
* sigproc.cc: Ditto.
* winsup.h (hExeced): Define here.
* fhandler_virtual.cc (fhandler_virtual::fixup_after_exec): Just call close()
to reinitialize things to known state.
2005-07-05 03:16:46 +00:00
Christopher Faylor b945228cb6 * fhandler_console.cc (fhandler_console::read): Fix a compiler warning. 2005-06-11 05:09:25 +00:00
Christopher Faylor 8ad65ff049 * cygtls.cc (_cygtls::remove): Clear exitsock after close.
* fhandler_console.cc (fhandler_console::write_normal): Store character in a
local variable for potential future inspection.
2005-05-11 03:33:38 +00:00
Christopher Faylor c4ffa3c427 * shared_info.h (cygwin_shared_address): Bump to a higher value to avoid
collision with large data areas.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Accommodate changes to
open_shared arguments.
* fhandler_tape.cc (mtinfo_init): Ditto.
* pinfo.cc (pinfo::init): Use open_shared rather than win32 mmap calls.
* shared.cc (user_shared_initialize): Ditto.
(memory_init): Ditto.
(open_shared): Change to allow use a smore general mmap handler.
* shared_info.h (shared_locations): Add SH_JUSTCREATE, SH_JUSTOPEN.
(open_shared): Change declaration to match new usage.
* autoload.cc (LoadDLLfuncEx2): Define in terms of LoadDLLfuncEx3.
(LoadDLLfuncEx3): New macro.
2005-04-28 23:59:44 +00:00
Christopher Faylor 098a429002 * fhandler.h (dev_console::set_color): Define new function.
(dev_console::set_default_attr): Ditto, moved from fhandler_console.
(dev_console::fillin_info): Ditto.  Accommodate this change throughout this
file.
(fhandler_console::get_win32_attr): Eliminate.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Properly set default
attributes on initialization.
(fhandler_console::open): Set current attributes rather than default color on
open.
(fhandler_console::get_win32_attr): Eliminate.
(dev_console::set_color): New function.  Move get_win32_attr stuff here.
(dev_console::set_default_attr): New function, moved from fhandler_console.
(dev_console::fillin_info): Ditto.
(fhandler_console::char_command): Call set_color to set screen characteristics.
2005-04-22 17:03:38 +00:00
Corinna Vinschen a435749dc2 * fhandler_console.cc (get_win32_attr): Avoid inappropriate intensity
interchanging that used to render reverse output unreadable when
	non-reversed text is bright.
2004-12-16 13:19:08 +00:00
Corinna Vinschen 988566db0c * fhandler_console.cc (read): Consider offset within scrolling
region of the console window.
2004-12-14 12:09:51 +00:00
Christopher Faylor 8cb359d947 * child_info.h (child_info_spawn::hexec_proc): Eliminate.
* dcrt0.cc (dll_crt0_0): Remove hexec_proc stuff.
* fork.cc (fork_child): Remove call to pinfo_fixup_after_fork.
* pinfo.cc (set_myself): Close and zero pid_handle if set.
(pinfo_fixup_after_fork): Delete.
(proc_waiter): Don't close vchild.hProcess here.  Do that when we are remove
the vchild from procs.  Save hProcess as pid_handle only on first reparent
operation.
(pinfo::wait): Don't set pid_handle here.
(pinfo::alert_parent): Always try to send signal.  If unsuccessful then close
and zero wr_proc_pipe.
* pinfo.h (pinfo::pinfo): Make sure that appropriate parts of the class are
zeroed on construction.
(pinfo::alert_parent): Take char argument.
(pinfo_fixup_after_fork): Delete declaration.
(hexec_proc): Ditto.
* sigproc.cc (remove_proc): Close pid_handle and hProcess if appropriate.
* spawn.cc (spawn_guts): Set cygheap->pid_handle on first exec.
* cygheap.h (init_cygheap::pid_handle): New element.
* pinfo.cc (set_myself): Clear previously existing cygheap->pid_handle when a
new process has been started.
(pinfo::wait): Make sure that a handle to the newly forked/spawned process is
kept around so that the pid will not be reused.
* pinfo.h (_pinfo::pid_handle): Move.
(pinfo::pid_handle): to here.
* spawn.cc (spawn_guts): Create a pid_handle in cygheap prior to spawning to
ensure that the pid does not get reused during the lifetime of the "cygwin
pid".
* pinfo.h (pinfo::alert_parent): New function.
* exceptions.cc (sig_handle_tty_stop): Use alert_parent to send "signals" to
parent.
* fork.cc (fork_parent): Don't close pi.hProcess.  Let the waiter thread do
that.
* pinfo.cc (proc_waiter): Detect case where process exits without setting the
exit code and use value from GetExitCodeProcess.  Reluctantly implement
__SIGREPARENT.
(pinfo::alert_parent): Define.
* sigproc.h (__SIGREPARENT): New enum.
* spawn.cc (spawn_guts): Send reparent signal to parent on exec.  Always create
process in suspended state to avoid races.  Remove cygthread.h in favor of
cygtls.h throughout since cygtls now includes cygthread.h.  Eliminate
ppid_handle usage throughout.
* child_info.h: Regenerate magic number
(child_info): Remove pppid_handle.
* cygthread.h (cygthread::release): New method.  Frees thread without waiting.
* cygthread.cc (cygthread::stub): Set _ctinfo in _mytls to point to information
for executing thread.  Don't call SetEvent if thread is no longer in use.
(cygthread::simplestub): Ditto.
* cygtls.h (_cygtls::_ctinfo): New element contains pointer to information
about executing cygthread, if any.
* dcrt0.cc: Remove last vestiges of per_thread stuff.
(dll_crt0_0): Ditto.  Remove accommodation for ppid_handle.
(do_exit): Remove obsolete reparenting test.
(_exit): Exit with a more SUSv3-like exit value.
* dtable.cc (dtable::stdio_init): Check for myself->cygstarted rather than
myself->ppid_handle to see if we were started by a cygwin process.
* exceptions.cc (open_stackdumpfile): Ditto.
(handle_exceptions): Ditto.
(ctrl_c_handler): Ditto.
(sig_handle_tty_stop): Ditto.  Let parent send signal to itself on STOP.
(sigpacket::process): Comment out vfork test.
(signal_exit): Use more SUSv3-like exit value on signal.
* external.cc (fillout_pinfo): Don't set hProcess.
* fork.cc: Remove VFORK cruft.
(per_thread::set): Delete.
(fork_child): Remove perthread stuff.
(fork_parent): Remove obsolete subproc_init.  Accommodate new method for
tracking subprocesses.
* pinfo.cc (set_myself): Accommodate new pinfo/_pinfo layout.  Set some things
here that used to be set in wait_sig.
(_pinfo::exit): Set exitcode here.  Close process pipe.
(_pinfo::commune_send): Accommodeate new pinfo/_pinfo layout.
(proc_waiter): New function.  Waits, in a thread for subprocess to go away.
(pinfo::wait): New function.  Initialization for proc_waiter.
* pinfo.h (_pinfo::exitcode): New element.
(_pinfo::cygstarted): Ditto.
(_pinfo::wr_proc_pipe): Ditto.
(_pinfo::ppid_handle): Delete.
(_pinfo::hProcess): Delete.
(_pinfo::lock): Delete.
(pinfo::hProcess): New element.
(pinfo::lock): Ditto.
(pinfo::wait): Declare new function.
(pinfo::preserve): Define new function.
* sigproc.cc: Remove old stuff from wait_subproc thread based method.
(zombies): Remove.
(procs): New.
(my_parent_is_alive): Just check that the parent pid exists.
(mychild): Just use pinfo methods to determine if child is mine.
(proc_subproc): Revamp PROC_ADDCHILD to use pinfo::wait.  Remove
PROC_CHILDTERMINATED logic.  Use different method to remove processes from list
when SIGCHLD == SIG_IGN.
(proc_terminate): Gut.
(subproc_init): Delete.
(init_child_info): Remove setting of pppid_handle.
(checkstate): Revamp to only scan procs array.
(remove_proc): Rename from remove_zombie.  Don't close hProcess or pid_handle.
Don't release memory if it's myself.
(stopped_or_terminated): Change logic to handle new consolidated proc/zombie
array.
(wait_subproc): Delete.
* sigproc.h: Remove obsolete EXIT_* defines.
(subproc_init): Remove declaration.
* spawn.cc (spawn_guts): Remove reparenting stuff.  Use standard wait logic to
wait for child if started from a non-cygwin process.
* tlsoffsets.h: Regenerate.
* tty.cc (tty_init): Check for myself->cygstarted rather than
myself->ppid_handle to see if we were started by a cygwin process.
* include/sys/signal.h (external_pinfo::exitcode): Replace hProcess.
* include/sys/wait.h (WCOREDUMP): Define.
* fhandler_tty.cc (fhandler_tty_slave::read): Add debugging output for timeout
case.
* signal.cc (abort): Flag that we are exiting with the ABORT signal.
2004-11-26 04:15:10 +00:00
Christopher Faylor f054a20f1a * fhandler_console.cc (fhandler_console::fixup_after_exec): Fix error message. 2004-10-20 01:02:18 +00:00
Christopher Faylor e3778517d9 * path.cc (chdir): Always use the normalized_path as posix_cwd, except if it
starts with a drive.

Also perform whitespace cleanup.
2004-05-28 19:50:07 +00:00
Christopher Faylor 641654f72a Change the name "title_mutex" to "tty_mutex" throughout.
* tty.h (tty_list::allocate_tty): Turn argument into a boolean.
* tty.cc (tty_list::init): Protect entire allocation operation with tty_mutex
(formerly title_mutex) to protect against allocation races.
2004-05-17 15:27:56 +00:00
Christopher Faylor 0c565ab35b * cygthread.cc (cygthread::is): Eliminate.
* cygthread.h (cygthread::is): Eliminate declaratin.
* fhandler_console.cc (fhandler_console::read): Only wait for signal_arrived in
the main thread.
* fhandler_socket.cc: Include new "wininfo.h".
(fhandler_socket::ioctl): Use 'winmsg' rather than 'gethwnd()'.
* sync.cc (muto::grab): Define new function.
(muto::acquire): Use tls pointer rather than tid.
(muto::acquired): Ditto.
(muto::reset): Delete.
(muto::release): Ditto.  Also implement "close on last release".
* sync.h (muto::tid): Delete.
(muto::tls): New field.
(muto::ismine): Delete.
(muto::owner): Delete.
(muto::unstable): Delete.
(muto::reset): Delete.
(muto::upforgrabs): New method.
(muto::grab): Ditto.
(new_muto_name): New define.
* wininfo.h: New file.
(wininfo): New class.
* window.cc: Rework throughout to use winfo class for controlling invisible
window operation.
(gethwnd): Delete definition.
* winsup.h (gethwnd): Delete declaration.
2004-05-16 04:18:50 +00:00
Corinna Vinschen 56551a9bfb * Use new unified status_flag accessor methods from classes fhandler_*,
tty_min, mtinfo and fs_info thoroughout.
	* fhandler.h: Redefine all set_close_on_exec methods to take a bool
	argument.
	(enum conn_state): Rename from connect_state.
	(class fhandler_base): Rename some status flags to align with
	accessor method names.  Drop encoded flag entirely.  Unify status
	accessor methods.  Const'ify all read accessor methods.
	(class fhandler_socket): Ditto.
	(class fhandler_dev_raw): Ditto.
	* fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat()
	instead of evaluating FATness of file system here.
	(fhandler_disk_file::opendir): Drop call to set_encoded().
	(fhandler_disk_file::readdir): Use pc.isencoded() directly.
	* mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods.
	* path.cc (fsinfo_cnt): Add.
	(fs_info::update): Accomodate class changes. Evaluate file system
	name specific flags right here. Add thread safety for reading and
	writing global fsinfo array.
	* path.h (enum path_types): Drop values for flags kept in fs already.
	(struct fs_info): Move status informatin into private struct type
	status_flags.  Add accessor methods. Remove path and file system
	name string arrays in favor of status bits.
	(class path_conv): Use new fs_info status information where
	appropriate.
	(path_conf::fs_has_ea): Rename from fs_fast_ea.
	(path_conf::fs_has_acls): New method.
	(path_conf::root_dir): Remove.
	(path_conf::volname): Remove.
	* syscalls (statfs): Evaluate root dir locally.
	* tty.h (class tty_min): Unify status accessor methods.  Const'ify
	all read accessor methods.
2004-04-10 13:45:10 +00:00
Corinna Vinschen 7aa88267c1 * fhandler.h (fhandler_base::status): Declare private.
(fhandler_base::open_status): Ditto.
	(class fhandler_socket): Move status bits into private bitfield struct
	type status_flags.  Change accessor methods appropriately.
	* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
	above status bit changes.
	* tty.h: Remove status bit enumerator.
	(TTYISSETF): Remove.
	(TTYSETF): Remove.
	(TTYCLEARF): Remove.
	(TTYCONDSETF): Remove.
	(tty_min::status): Define as private bitfield struct type status_flags.
	Add appropriate accessor methods.
	* fhandler_console.cc: Use tty_min::status accessor methods throughout.
	* fhandler_termios.cc: Ditto.
	* winsup.h (__ISSETF): Remove.
	(__SETF): Remove.
	(__CLEARF): Remove.
	(__CONDSETF): Remove.
2004-04-09 12:09:45 +00:00
Christopher Faylor cec4879206 * debug.h (console_printf): Define for non-debugging condition.
* cygtls.h (_threadinfo::lock): Remove wait argument.
(_threadinfo::interrupt_setup): Remove retaddr argument.
* exceptions.cc (_threadinfo::interrupt_setup): Ditto.
(_threadinfo::interrupt_now): Accommodate change to interrupt_setup argument.
(setup_handler): Ditto.  Always lock sig stack prior to determining interrupt
method.
* gendef (_sigfe): Correct thinko regarding cmpxchg.
(_sigbe): Ditto.
(_threadinfo::lock): Ditto.
(_threadinfo::pop): Eliminate left-over stack unlock.
* sigproc.cc (proc_subproc): Chnage debugging output to printed warning.
2004-02-09 04:04:24 +00:00
Christopher Faylor 528060195c * fhandler.h (*::fixup_after_exec): Eliminate unused handle argument.
* fhandler.h (dtable::fixup_after_exec): Eliminate unused handle argument.
* dcrt0.cc (dll_crt0_1): Reflect elimination of unused handle argument to
fixup_after_exec.
* dtable.cc (dtable::fixup_after_exec): Ditto.
* fhandler_console.cc (fhandler_console::fixup_after_exec): Ditto.
* fhandler_dsp.cc (fhandler_dsp::fixup_after_exec): Ditto.
* fhandler_raw.cc (fhandler_raw::fixup_after_exec): Ditto.
* fhandler_socket.cc (fhandler_socket::fixup_after_exec): Ditto.
* fhandler_virtual.cc (fhandler_virtual::fixup_after_exec): Ditto.
* pipe.cc (fhandler_pipe::fixup_after_exec): Ditto.
* spawn.cc (spawn_guts): Do not set ciresrv.parent.
* child_info.h (child_info_spawn::~child_info_spawn): Do not close parent.
Update CURR_CHILD_INFO_MAGIC.
* dcrt0.cc (dll_crt0_0): Do not close spawn_info->parent.  Pass NULL to
cygheap->fdtab.fixup_after_exec().
2004-02-02 21:00:07 +00:00
Christopher Faylor 6027d26d8b Throughout, change name from set_inheritance to set_no_inheritance to better
reflect input arguments of this function.
* cygheap.h (CYGHEAPSIZE): Increase size of cygheap to something closer to the
21st century.
2004-02-02 20:33:09 +00:00
Christopher Faylor 46ee54222e * fhandler_console.cc (fhandler_console::close): Remove obsolete test for
vfork_cleanup.
* pipe.cc (fhandler_pipe::close): Add comment.
2004-01-17 03:47:27 +00:00
Christopher Faylor ac02533e08 * gentls_offsets: Reinstate unlink of temp files.
* fhandler_console.cc (fhandler_console::close): Fix debugging output.
(fhandler_console::fixup_after_fork): Decrement open_fhs prior to call to
fhandler_console::open since this would cause incrementing too much
incrementing in child processes.  (Probably needs to be handled more elegantly
someday)
(fhandler_console::fixup_after_exec): Ditto.
2004-01-15 19:51:49 +00:00
Christopher Faylor 8ed5c9b629 Move open_fhs from fhandler.h to cygheap.h for easier tracking. Accommodate
this change throughout.
* dtable.cc (dtable::add_archetype): Use correct count when iterating through
*active* archetypes.
* dtable.cc (dtable::fixup_after_exec): Close handle if close_on_exec and
archetype exists since archetype currently does not set windows close-on-exec
flag (FIXME).
* fhandler_tty.cc (fhandler_tty_slave::open): Change debugging output slightly.
(fhandler_tty_slave::close): Ditto.
(fhandler_tty_slave::fixup_after_fork): Just report on inherited use counts
since since archetype currently does not set windows close-on-exec flag
(FIXME).
* pinfo.cc (_pinfo::set_ctty): Change debugging output slightly.
* cygheap.cc (cygheap_init): Remove open_fhs accommodation and use count
reporting.
* perthread.h (vfork_save::fhctty): New element.
* perthread.h (vfork_save::open_fhs): New element.
* fork.cc (vfork): Muck around with ctty and open_fhs stuff, both of which are
now saved in the vfork_save structure.
2003-12-30 01:57:16 +00:00
Christopher Faylor 8e10c4311f * cygheap.h (cygheap_types): Add HEAP_ARCHETYPES.
(init_cheap::ctty): Change to pointer.
* dtable.h (dtable::find_archetype): Declare new function.
(dtable::add_archetype): Declare new function.
(dtable::delete_archetype): Declare new function.
(dtable::narchetypes): Declare.
(dtable::farchetypes): Declare.
(dtable::initial_archetype_size): Declare.
(dtable::dtable): Initialize new fields.
(dtable::initial_archetype_size): Declare.
* dtable.cc (dtable::find_archetype): Define new function.
(dtable::add_archetype): Define new function.
(dtable::delete_archetype): Define new function.
(dtable::initial_archetype_size): Define.
* fhandler.h (fhandler_base::archetype): Declare.
(fhandler_base::usecount): Declare.
* fhandler.cc (fhandler_base::fhandler_base): Initialize new fields.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Pass NULL to third
argument of set_ctty.
* fhandler_tty.cc (fhandler_tty_slave::open): Accommodate new archetype method
to create only one instance of a tty.
(fhandler_tty_slave::close): Don't close handles unless archetype usecount is
zero.  When that happens, close archetype too.
(fhandler_tty_slave::dup): Just copy archetype.  Set use count appropriately.
Set ctty, if appropriate.
(fhandler_tty_common::dup): Remove slave considerations.
(fhandler_tty_common::set_close_on_exec): Remove cygheap->ctty considerations.
* pinfo.cc (_pinfo::set_ctty): Accommodate new archetype methods.
* pinfo.h (_pinfo::set_ctty): Make third argument explicit.
* syscalls.cc (close_all_files): Decrement controlling tty use count before
closing all handles to allow controlling tty to be closed.  Remove previous
controlling tty considerations.
2003-12-11 06:12:41 +00:00
Christopher Faylor 2e008fb91f Change use of BOOL, TRUE, FALSE to bool, true, false, as appropriate,
throughout.
* tty.cc (tty::common_init): Remove call to SetKernelObjectSecurity and edit
some comments.
* cygheap.h (init_cygheap::ctty): Add new element.
* devices.in (device::parse): Remove special handling for /dev/tty.
* devices.cc: Regenerate.
* dtable.cc (build_fh_pc): Don't reset /dev/tty device.  Let the device opener
do that.
* fhandler_termios.cc (tty_min::set_ctty): Redefine to _pinfo class.
* fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Avoid setting
noninherit flag for ctty.
* tty.h: Move BOOLs to bools.
(tty_min::set_ctty): Redeclare to _pinfo class.
* pinfo.cc (_pinfo::set_ctty): Define new function based on tty_min::set_ctty.
Change first argument from tty number to tty_min class.
* pinfo.h (_pinfo::set_ctty): Declare.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Reflect move of
set_ctty to _pinfo class.
* fhandler_tty.cc (fhandler_tty_slave::open): Treat FH_TTY specially.  Use
saved cygheap value if it exists.  Otherwise convert to real device and save on
first time open.
(fhandler_tty_common::dup): Potentially set controlling tty if duping a slave
tty.
* syscalls.cc (setsid): Close controlling tty in cygheap.
* tty.cc: Change some BOOLs to bools.
2003-12-07 22:37:12 +00:00
Corinna Vinschen abfc9c412c * dcrt0.cc: Remove local variable alternate_charset_active.
* fhandler.h: Add variable alternate_charset_active, functions
	str_to_con, con_to_str to dev_console structure.
	* fhandler_console.cc (con_to_str): Move function into dev_console
	class.
	(str_to_con): Ditto.
	(fhandler_console::read): Call con_to_str on dev_state.
	(fhandler_console::write_normal): Call str_to_con on dev_state.
	(fhandler_console::char_command): Change active_charset_active
	assignment to be on dev_state.
	* winsup.h: Remove global external variable alternate_charset_active.
2003-10-16 14:08:28 +00:00
Corinna Vinschen ce34c904cc * fhandler_console.cc (char_command): Add escape sequence for codepage
ansi <-> oem switching for ncurses frame drawing capabilities.
	* dcrt0.cc: Add local variable alternate_charset_active.
	* winsup.h: Add global external variable alternate_charset_active.
2003-10-15 08:23:26 +00:00
Christopher Faylor 63726a5eb4 * fhandler_console.c (fhandler_console::read): Record the state of the SHIFT,
CTRL and ALT keys at the time of the last keyboard input event.
(fhandler_console::ioctl): Handle requests to retrieve the keyboard modifiers
via the TIOCLINUX command.
* fhandler_tty.c (fhandler_tty_slave::read): Ditto.
* include/sys/termios.h (TIOCLINUX): New macro definition.
2003-09-27 02:36:50 +00:00
Christopher Faylor 7ac6173643 * devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file.  Reorganize headers so that path.h precedes
fhandler.h throughout.  Remove device argument and unit arguments from fhandler
constructors throughout.  Remove pc arguments to fhandler functions and use
internal pc element instead, throughout.  Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class.  Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices.  Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name.  Move
out of dtable class.  Don't accept a path_conv argument.  Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler.  Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler.  Move out of dtable class.
Simplify arguments to just take new 'device' type and a name.  Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element.  Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access.  Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe.  Change arguments to accept
fhandler_pipe array.  Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately.  Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument.  Call build_fh_name to construct
fhandler.  Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access.  Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff.  Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff.  Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here.  Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 00:37:18 +00:00
Christopher Faylor 3ef50005c7 * dcrt0.cc (dlL_crt0_1): Set __argc_safe after __argc is absolutely know to be
set.
* exceptions.cc (sig_handle_tty_stop): Don't reset sigCONT event since it is
reset automatically.
* fork.cc (fork): Remove obsolete usage of PID_SPLIT_HEAP.
* include/sys/cygwin.h: Ditto.
* sigproc.cc (sig_send): Use sigframe init method to set frame since it checks
for previous ownership of the frame.
* sigproc.h (sigframe::init): Accept an "is_exception" argument.
2003-09-09 03:11:31 +00:00
Christopher Faylor c6f53ff6be * dcrt0.cc (__argc_safe): New variable.
(dll_crt0_1): Store argc in __argc_safe, which will theoretically remain
untouched by the user.
* fhandler_console.cc (fhandler_console::read): Silence some compiler warnings.
* fhandler_raw.cc (fhandler_dev_raw::raw_read): Ditto.
* pinfo.cc (_pinfo::commune_recv): Carefully bound argv scan and check for
potentially bad pointers since user could have set argv cell to anythinw.
* cygheap.h (CYGHEAPSIZE): Bump up size.
2003-09-05 01:55:01 +00:00
Christopher Faylor c433f4617f Throughout, remove "include <errno.h>" from files which already include
cygerrno.h.
* include/cygwin/config.h (__DYNAMIC_REENT__): Define.
* include/cygwin/version.h: Bump API minor version.
* cygwin.din: Export __getreent
* cygerrno.h: Include errno.h.  Fix places where _impure_ptr is used directly
to store the errno value.
* debug.cc (__set_errno): Ditto.
* errno.cc: Remove _RRENT_ONLY define to get errno.cc compiled.
* signal.cc: Rename _reent_clib to _REENT throughout.
* thread.h (reent_clib): Remove prototype.
* thread.cc (reent_clib): Rename reent_clib to __getreent.  Return _impure_ptr
until MTinterface is initialized.
(reent_winsup): Fix a possible SEGV when _r == NULL.  Return NULL instead.
* MTinterface::fixup_after_fork: Switch reent back to _impure_ptr to keep
signal handling running when fork is called from a thread other than the
mainthread.
2003-06-16 03:24:13 +00:00
Christopher Faylor ca81cd60ce * fhandler_console.cc (fhandler_console::read) Handle certain key up events, to
allow pasting accented characters and typing them using the "alt + numerics"
sequences.
* include/limits.h (IOV_MAX): Set to a number which is small enough to use in
an array.
2003-04-08 21:19:33 +00:00
Christopher Faylor d99c61760e * external.cc (check_ntsec): New function.
(cygwin_internal): Add CW_CHECK_NTSEC handling to call check_ntsec() from
applications.
* include/cygwin/version.h: Bump API minor number.
* include/sys/cygwin.h (cygwin_getinfo_types): Add CW_CHECK_NTSEC.
* cygthread.cc (cygthread::new): Add more defensive debugging.
2003-04-02 23:01:11 +00:00
Christopher Faylor 3543669fd3 * cygwin.din: Export btowc, trunc.
* include/cygwin/version.h: Reflect new exports.
* syscalls.cc (_stat): Rename to stat to avoid newlib wrapper.
* syscalls.cc (_fstat): Ditto.
* fhandler_console.cc (fhandler_console::close): Correct check for current tty.
Add debugging output when console is freed.
(set_console_state_for_spawn): Add debugging output.
* fhandler_tty.cc (fhandler_tty_slave::open): Don't decrement console open flag
when vforking.
* sigproc.cc (sigproc_terminate): Fix debugging output.
* spawn.cc (handle): Eliminate second argument.
(spawn_guts): Reflect elimination of argument change to handle.
* syscalls.cc (setsid): Add debugging output when console is freed.
* syscalls.cc (rename): Revert assumption that DELETE_ON_CLOSE works on Win9x.
2003-03-17 19:08:11 +00:00
Christopher Faylor 41ffdfa51e * include/cygwin/version.h: Bump DLL minor number to 23. 2003-03-13 23:11:38 +00:00
Christopher Faylor d5d2ffee38 * fhandler_console.cc (fhandler_console::close): Don't decrement in use counter
if in vfork fixup stage.
2003-03-03 03:58:10 +00:00
Christopher Faylor 8b19b43d00 * dll_init.cc (dll_list::load_after_fork): Don't revert to LoadLibrary if
LoadLibraryEx fails.
* dtable.cc (dtable::dec_console_fds): Eliminate.
(dtable::release): Don't treat console specially.
(dtable::build_fhandler): Ditto.
* dtable.h (console_fds): Eliminate.
(dtable::dec_console_fds): Eliminate.
(dtable::inc_console_fds): Eliminate.
* fhandler.h (fhandler_console::open_fhs): New static element.
* fhandler_console.cc (fhandler_console::open): Increment open_fs.
(fhandler_console::close): Call FreeConsole if no more open consoles and ctty
is not associated with the console.
* syscalls.cc (setsid): Simplify check for when to call FreeConsole.
(check_pty_fds): Eliminate definition.
* winsup.h (check_pty_fds): Eliminate declaration.
2003-03-02 18:37:17 +00:00
Christopher Faylor d1d1797eb7 * fhandler_console.cc (fhandler_console::write_normal): Use MessageBeep for
bell sound.
* autoload.cc (MessageBeep): Add.
2003-02-13 23:51:41 +00:00
Christopher Faylor 335556d58b Eliminate most unneeded this-> pointers throughout. 2003-02-04 03:01:17 +00:00
Christopher Faylor 45dbfc2611 * fhandler_console.cc (fhandler_console::send_winch_maybe): Reset scroll region
if size changes.
2003-01-25 01:17:51 +00:00
Corinna Vinschen e136dbc297 Split ChangeLog, create ChangeLog-2002.
Fix copyright dates.
2003-01-10 12:32:49 +00:00
Christopher Faylor 66dcfc4498 * fhandler.h (fhandler_tty_master::set_winsize): Declare new function.
* fhandler_console.cc (fhandler_console::send_winch_maybe): If appropriate,
call tty master function to handle screen size change.
* fhandler_tty.cc (fhandler_tty_master::set_winsize): New function.
(fhandler_tty_master::init): Call set_winsize to set initial screen size.
2002-12-27 05:31:30 +00:00
Christopher Faylor 46b73ef192 * fhandler.h (fhandler_termios::line_edit): Replace third argument with
passed-in termios struct.
* fhandler_console.cc (fhandler_console::read): Prior to loop, make a copy of
current termios for passing to line_edit prior so that all characters are
processed consistently.
* fhandler_tty.cc (fhandler_pty_master::write): Ditto.
(process_input): Make a copy of curent termios prior to read for use in
subsequent line_edit.
* fhandler_termios.cc (fhandler_termios::line_edit): Replace third parameter
with passed-in termios struct and use it throughout rather than the data from
the current fhandler_termios class.
2002-12-27 03:50:29 +00:00
Christopher Faylor 8bce0d723c Throughout, change fhandler_*::read and fhandler_*::raw_read to void functions
whose second arguments are both the lenght and the return value.
* fhandler.cc (fhandler_base::read): Rework slightly to use second argument as
input/output.  Tweak CRLF stuff.
(fhandler_base::readv): Accommodate fhandler_*::read changes.
* cygthread.h (cygthread::detach): Declare as taking optional handle argument.
(cygthread::detach): When given a handle argument, wait for the handle to be
signalled before waiting for thread to detach.  Return true when signal
detected.
2002-12-14 04:01:32 +00:00
Christopher Faylor 49dd6fc61e * fhandler.h (fhandler_termios::line_edit): Change return from an int to an
enum to allow the function to return an error.
* fhandler_console.cc (fhandler_console::read): Update the line_edit call to
use the new enum.
* fhandler_termios.cc (fhandler_termios::line_edit): Change return from an int
to an enum to allow the function to return an error.  Put put_readahead call
before doecho for future patch.
* fhandler_tty.cc (fhandler_pty_master::write): Change to call line_edit one
character at a time, and stop if an error occurs.
2002-12-05 16:24:52 +00:00
Christopher Faylor 6597785dc2 * exceptions.cc (setup_handler): Add debugging output. Set thread priority to
idle if pending signals to allow other threads to get into interruptible state.
* miscfuncs.cc (sys_mbstowcs): Save current thread in variable to avoid an OS
call.
* wait.cc (wait_sig): Reset thread priority each time through loop since the
priority may have been set down to deal with pending signals.
2002-11-15 04:35:13 +00:00
Christopher Faylor 33902276b1 checking previously ChangeLog'ed file. 2002-11-14 18:02:05 +00:00
Christopher Faylor c0a02a4b42 * miscfuncs.cc (low_priority_sleep): New function. Use throughout where code
is supposed to be giving up time slice.
* fhandler_console.cc (fhandler_console::read): Switch button 2/3 output escape
sequences to be consistent with xterm.
2002-11-13 19:36:12 +00:00
Christopher Faylor c8fae3c17b * fhandler_console.cc (keytable[]): Revert previous change. It would break too
many things.
2002-11-07 03:35:02 +00:00
Christopher Faylor c759d297b2 * syscalls.cc (getutid): Use UT_IDLEN where appropriate. 2002-11-07 02:50:50 +00:00
Christopher Faylor fdb28b5e5f * child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
(child_info_fork::mount_table): Remove.
(child_info_fork::myself_addr): Remove.
* fork.cc (fork_child): Don't set either of the above.
* dcrt0.cc (dll_crt0_1): Call memory_init as early as possible.
* fhandler_console.cc (console_state): Move to shared_info.h.
(fhandler_console::get_tty_stuff): Reflect open_shared arg change.
* pinfo.cc (myself_addr): Remove definition.
(pinfo::init): Get myself address from open_shared.
* pinfo.h (myself_addr): Remove declaration.
* shared.cc (open_shared): Rework so that known shared memory locations are
protected.  Take shared memory type as fifth argument.
(memory_init): Reflect open_shared arg change.
* shared_info.h (shared_locations): New enum.
(console_state): Move here.
(open_shared): Reflect open_shared arg change in declaration.
2002-10-15 07:03:45 +00:00
Christopher Faylor 54030e2146 * child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
(child_info_fork::heaptop): Remove obsolete element.
(child_info_fork::heabbase): Ditto.
(child_info_fork::heapptr): Ditto.
(child_info_fork::mount_table): New element.
(child_info_fork::myself_addr): Ditto.
* dcrt0.cc (dll_crt0_1): Set mount_table and myself_addr when forking.
(initial_env): Add newline to "sleeping" message.
* dll_init.cc (reserve_upto): Accommodate cygwin heap when freeing memory.
Make debugging output a little more descriptive.
* fork.cc (fork_parent): Save mount_table and myself_addr.
* pinfo.cc (myself_addr): New variable.
(set_myself): Pass PID_MYSELF flag to init.
(pinfo::Init): Honor PID_MYSELF.  Save address where myself shared memory
resides in myself_addr, for fork.
* pinfo.h (myself_addr): Declare.
* shared.cc (memory_init): On fork, use previously saved address for location
of mount table.
* include/sys/cygwin.h (PID_MYSELF): New value.
* dtable.cc (dtable::stdio_init): Don't pass access type to
init_std_file_from_handle.  It's always the same.
(dtable::init_std_file_from_handle): Remove access type argument.  Assume
read/write.
* dtable.h (dtable::init_std_file_from_handle): Ditto for declaration.
* exceptions.cc (try_to_debug): Don't try to debug if already being debugged.
* fhandler_console.cc (shared_console_info_save): New variable.
(fhandler_console::get_tty_stuff): Save address of shared console stuff for
fork.
2002-10-14 20:25:52 +00:00
Christopher Faylor 7da53596cf * cygheap.cc (dup_now): Make fatal error a little more informative.
(cygheap_setup_for_child): Detect when default size of shared region is less
than the current size and allocate that much.
(_cbrk): Just return NULL on inability to allocate.
(_cmalloc): Ditto.
* cygheap.h (CYGHEAPSIZE): Change size to reflect newer, tinier fhandler sizes.
* spawn.cc (av::error): New element, reflects potential errno from cmalloc.
(av::~av): Don't free NULL pointers.
(av::replace0_maybe): Detect out-of-memory conditions.
(av::dup_maybe): Ditto.
(av::dup_all): Ditto.
(av::unshift): Ditto.
(spawn_guts): Set errno and return if argv creation ran into problems.
* fhandler.h (fhandler_union): Change member names to something safer.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Always set
fhandler_console::dev_state regardless of whether shared region is initialized.
* cygthread.cc (cygthread::runner): Use ExitThread rather than return
(planning for future).
2002-10-09 04:08:05 +00:00
Christopher Faylor 3c66c0707c * fhandler.h (dev_console): New class.
(fhandler_console::dev_state): New class element.
(fhandler_console::mouse_aware): Use dev_state element.
(fhandler_console::get_tty_stuff): Declare new function.
* fhandler_console.cc: Use dev_state fhandler_console element, throughout.
(fhandler_console::get_tty_stuff): Move to fhandler_console class.  Incorporate
dev_console information.  Move constructor stuff here.
2002-10-08 06:16:16 +00:00
Christopher Faylor c90e1cf179 * fhandler.cc (fhandler_base::dup): Don't set handle on failure. Caller has
already taken care of that.
* fhandler_console.cc (fhandler_console::open): Initialize handles to NULL.
(fhandler_console::close): Ditto.  GNUify non-GNU formatted functions calls
throughout.
2002-09-22 03:38:57 +00:00
Christopher Faylor 580e99a151 Cleanup calls to CreateFile throughout.
* dcrt0.cc (__api_fatal): Correctly check for failing return from CreateFile.
* assert.cc (__assert): Don't check return value from CreateFile for NULL.
* fhandler_console.cc (set_console_state_for_spawn): Ditto.
* fork.cc (fork_parent): Ditto.
2002-09-19 15:12:48 +00:00
Christopher Faylor 5bf785a017 * cygthread.cc (cygthread::initialized): Avoid copying on fork or some threads
may not end up in the pool.
(cygthread::new): Avoid race when checking for initialized.  Add debugging
code.
* fhandler.cc (fhandler_base::raw_read): Add case for ERROR_INVALID_HANDLE due
to Win95 directories.
(fhandler_base::open): Handle errors due to Win95 directories.
(fhandler_base::close): Add get_nohandle () test.
(fhandler_base::set_close_on_exec): Ditto.
(fhandler_base::fork_fixup): Ditto.
(fhandler_base::lock): Change error code to Posix EINVAL.
(fhandler_base::dup): If get_nohandle (), set new value to INVALID_HANDLE_VALUE
instead of NULL.
* fhandler_disk_file.cc (fhandler_disk_file::fstat): Call fstat_by_name if
get_nohandle ().  Remove extraneous element from strpbrk.
(fhandler_disk_file::open): Remove test for Win95 directory.
* fhandler_random.cc (fhandler_dev_random::open): Add set_nohandle ().
* fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
(fhandler_dev_zero::close): Delete.
* fhandler.h (class fhandler_dev_zero): Ditto.
2002-09-19 03:30:20 +00:00
Christopher Faylor c060edba34 * fhandler.h (fhandler_console::send_winch_maybe): New method.
* fhandler_console.cc (set_console_state_for_spawn): Remove if 0'ed code.
(fhandler_console::send_winch_maybe): Define new method.
(fhandler_console::read): Use send_winch_maybe where appropriate.
(fhandler_console::init): Just call all tcsetattr rather than output_tcsetattr.
* select.cc (peek_console): Reorganize so that send_winch_maybe is called for
everything but keyboard input.
2002-08-19 04:43:58 +00:00
Christopher Faylor b6bd703781 * Makefile.in (DLL_OFILES): Add cygthread.o.
* dcrt0.cc (dll_crt0_1): Eliminate various thread initialization functions in
favor of new cygthread class.
* debug.cc: Remove thread manipulation functions.
* debug.h: Ditto.
* external.cc (cygwin_internal): Use cygthread method for determining thread
name.  Remove capability for setting thread name.
* fhandler_console.cc (fhandler_console::read): Use cygthread method rather
than iscygthread function.
* fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Use cygthread
methods to create threads.
(fhandler_tty_common::__acquire_output_mutex): Use cygthread method to retrieve
thread name.
* select.cc (pipeinf): Use cygthread pointer rather than handle.
(start_thread_pipe): Ditto.
(pipe_cleanup): Ditto.
(serialinf): Ditto.
(start_thread_serial): Ditto.
(serial_cleanup): Ditto.
(socketinf): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Ditto.
* sigproc.cc (hwait_sig): Ditto.
(hwait_subproc): Ditto.
(proc_terminate): Ditto.
(sigproc_terminate): Ditto.
(sigproc_init): Initialize cygthread hwait_sig pointer.
(subproc_init): Initialize cygthread hwait_subproc pointer.
(wait_sig): Rely on cygthread HANDLE operator.
* strace.cc (strace::vsprntf): Use cygthread::name rather than threadname.
* window.cc (gethwnd): Use cygthread method to initialize thread.
2002-08-01 16:20:31 +00:00
Christopher Faylor eb5720f255 * fhandler_console.cc (fhandler_console::read): Use appropriate kill_pgrp
method.
* select.cc (peek_console): Ditto.
* fhandler_termios.cc (fhandler_termios::bg_check): Send "stopped" signal to
entire process group as dictated by SUSv3.
* termios.cc (tcsetattr): Detect when stopped signal sent and force a stop
before setting anything.
2002-07-29 03:18:41 +00:00
Christopher Faylor 0301bfd0ac * debug.h (handle_list): Move here from debug.cc. Add "inherit" flag
functionality.
* cygheap.cc (init_cheap): Move cygheap_max calculation to _csbrk.
(_csbrk): Reorganize to not assume first allocation is <= 1 page.
(cygheap_setup_for_child): Mark protected handle as inheritable.
* cygheap.h (cygheap_debug): New struct.
(init_cygheap): Add new structure when debugging.
* dcrt0.cc (dll_crt0_1): Remove call to debug_init.  Close ppid_handle here, if
appropriate.  Don't protect subproc_ready, since it is already protected in the
parent.  Call memory_init prior to ProtectHandle to ensure that cygheap is set
up.  Call debug_fixup_after_fork_exec when appropriate.
(_dll_crt0): Don't close ppid_handle here.
* debug.cc: Use cygheap debug structure rather than static elements throughout.
(add_handle): Don't issue a warning if attempt to protect handle in exactly the
same way from exactly the same place.  Add pid info to warning output.  Accept
additional argument controlling whether handle is to be inherited.  Add pid to
stored information.
(debug_fixup_after_fork_exec): Renamed from debug_fixup_after_fork.  Reorganize
to avoid erroneously skipping handles.
(mark_closed): Add pid info to warning output.
(setclexec): Rename from setclexec_pid.
* fhandler.cc (fhandler_base::get_default_fmode): Minor reorg.
(fhandler_base::fstat): Add debugging output.
(fhandler_base::set_inheritance): Call setclexec rather than setclexec_pid.
(fhandler_base::fork_fixup): Ditto.
* fhandler_console.cc (get_tty_stuff): Mark protected handle as inheritable.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
* tty.cc (tty::make_pipes): Ditto.
(tty::common_init): Ditto.
* fork.cc (fork_parent): Ditto.
(fork_child): Close protected handles with correct name.  Remove
debug_fixup_after_fork call.
* fhandler_socket.cc (fhandler_socket::create_secret_event): Mark protected
handle as inheritable/non-inheritable, as appropriate.
* shared.cc (memory_init): Mark protected handle as inheritable.  Call
debug_init here.
* sigproc.cc (wait_sig): Close protected handle with correct name.
* spawn.cc (spawn_guts): Rename spr to subproc_ready and mark it as
inheritable.
* exceptions.cc (debugger_command): Try to run dumper.exe, if found.
* syscalls.cc (fstat64): Don't follow symlinks for path_conv lookup since path
is already resolved.
2002-07-13 20:00:27 +00:00
Christopher Faylor 1bc9effd28 * fhandler_clipboard.c (fhandler_dev_clipboard::open): Force text mode.
* fhandler_console.cc (fhandler_console::open): *Really* force binary mode
rather than make it optional.
* fhandler_proc.cc (fhandler_proc::open): Ditto.
* fhandler_process.cc (fhandler_process::open): Ditto.
* fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Ditto.
* fhandler_registry.cc (fhandler_registry::open): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
* fhandler_virtual.cc (fhandler_virtual::open): Ditto.
* fhandler_windows.cc (fhandler_windows::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
* net.cc (fdsock): Ditto.
* path.cc (set_flags): Add more debugging.
2002-07-01 19:03:26 +00:00
Christopher Faylor f279e522b0 * autoload (noload): Avoid clobbering bx register.
* environ.cc (codepage_init): Use case insensitive match.
* fhandler_console.cc (cp_get_internal): Delete.
(con_to_str): Use get_cp to derive code page.
(str_to_con): Ditto.
* miscfuncs.cc (get_cp): New function.
(sys_wcstombs): New function.  Converted from macro.
(sys_mbstowcs): Ditto.
* winsup.h: Reflect above changes.
2002-06-26 05:29:41 +00:00
Christopher Faylor ce006ffa7f * dtable.cc (handle_to_fn): Attempt to handle "raw" accesses to remote shares.
* path.cc (mount_info::conv_to_win32_path): Set flags to binary when mount
entry is not found.
(mount_info::set_flags_from_win32_path): Ditto.
2002-06-05 04:01:43 +00:00
Christopher Faylor e35f391fa5 Remove fcntl.h includes throughout.
* fhandler.h: Move fcntl.h include here.
(fhandler_base::set_flags): Accept supplied_bin argument.  Make non-inlined.
* dtable.cc (dtable::init_std_file_from_handle): Just use binmode from pc.
(reset_to_open_binmode): Use set_flags.
* cygwin.din (open): Avoid newlib wrapper.
(read): Ditto.
(unlink): Ditto.
(write): Ditto.
* fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument.  Make
binmode decisions here.
(fhandler_base::open): Avoid using pc if it is NULL.  Eliminate binmode logic.
Just call set_flags with binmode argument.
(fhandler_base::init): Call set_flags with binmode argument.
* fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto.
* fhandler_console.cc (fhandler_console::open): Ditto.
(fhandler_console::init): Force binary on open.
* fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode here.
Let it happen in base class.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open.  Set return
value appropriately if unable to open.
* fhandler_proc.cc (fhandler_proc::open): Make sure flags are set before
open_status.
* fhandler_process.cc (fhandler_process::open): Ditto.
* fhandler_registry.cc (fhandler_registry::open): Ditto.
* fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default.
* fhandler_serial.cc (fhandler_serial::init): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
(fhandler_pty_master::open): Ditto.
* fhandler_virtual.cc (fhandler_virtual::open): Ditto.
* fhandler_windows.cc (fhandler_windows::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
* net.cc (fdsock): Ditto.
* path.cc (path_conv::check): Avoid checking for extension when error or
directory.
(set_flags): Set PATH_TEXT explicitly, when appropriate.
(mount_info::conv_to_win32_path): Use set_flags() to set path flags.
* path.h (PATH_TEXT): New enum.
(path_conv::binmode): Return appropriate constant based on binmode.
* pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY.
* syscalls.cc (setmode_helper): Make debugging message a little clearer.
(setmode): Set binmode via set_flags.
2002-06-05 01:42:28 +00:00
Christopher Faylor e02f1e9c81 * fhandler.cc (fhandler_base::open): Don't set binmode if already set. Don't
check for file.  Files should already be set.  Report on binary mode for
debugging.
(fhandler_base::fhandler_base): Don't set default binmode here.  That's for
later.
* fhandler_console.cc (fhandler_console::output_tcsetattr): Don't set binmode,
ever, for console.
* fhandler_disk_file.cc (fhandler_disk_file::open): Always set the binary mode
to the value derived from mount table.
* path.cc (mount_info::conv_to_win32_path): Default to binmode if path does not
translate into anything in the mount table.
2002-06-04 01:40:53 +00:00
Christopher Faylor 8e74c3207f * fhandler_console.cc (fhandler_console::open): Reinstate setting of flags. 2002-05-31 22:53:25 +00:00
Christopher Faylor de86e35bc4 * fhandler_console.cc (fhandler_console::open): Always default to binmode.
(fhandler_console::write_normal): Don't honor binmode setting.  There is
already a termios setting for this.
(fhandler_console::init): Correct argument order in init call.
2002-05-31 22:35:57 +00:00
Christopher Faylor 2402700d07 * autoload.cc (LoadFuncEx): Define via new LoadFuncEx2 macro.
(LoadFuncEx2): Adapted from LoadFuncEx.  Provides control of return value for
nonexistent function.
(NtQueryObject): Declare.
(IsDebuggerPresent): Declare via LoadFuncEx2 and always return true if not
available.
* debug.h (being_debugged): Just rely on IsDebuggerPresent return value.
* dtable.cc (handle_to_fn): New function.
(dtable::init_std_file_from_handle): Attempt to derive std handle's name via
handle_to_fn.
(dtable::build_fhandler_from_name): Fill in what we can in path_conv structure
when given a handle and path doesn't exist.
* fhandler.cc (fhandler_base::open): Don't set the file pointer here.  Use
pc->exists () to determine if file exists rather than calling GetFileAttributes
again.
* fhandler.h (fhandler_base::exec_state_isknown): New method.
(fhandler_base::fstat_helper): Add extra arguments to declaration.
(fhandler_base::fstat_by_handle): Declare new method.
(fhandler_base::fstat_by_name): Declare new method.
* fhandler_disk_file (num_entries): Make __stdcall.
(fhandler_base::fstat_by_handle): Define new method.
(fhandler_base::fstat_by_name): Define new method.
(fhandler_base:fstat): Call fstat_by_{handle,name} as appropriate.
(fhandler_disk_file::fstat_helper): Accept extra arguments for filling out stat
structure.  Move handle or name specific stuff to new methods above.
(fhandler_disk_file::open): Use real_path->exists rather than calling
GetFileAttributes again.
* ntdll.h (FILE_NAME_INFORMATION): Define new structure.
(OBJECT_INFORMATION_CLASS): Partially define new enum.
(OBJECT_NAME_INFORMATION): Define new structure.
(NtQueryInformationFile): New declaration.
(NtQueryObject): New declaration.
* path.cc (path_conv::fillin): Define new method.
* path.h (path_conv::fillin): Declare new method.
(path_conv::drive_thpe): Rename from 'get_drive_type'.
(path_conv::volser): Declare new method.
(path_conv::volname): Declare new method.
(path_conv::root_dir): Declare new method.
* syscalls.cc (fstat64): Send real path_conv to fstat as second argument.
2002-05-28 01:55:40 +00:00
Christopher Faylor d7b4a30001 Remove unneeded sync.h, where appropriate, throughout. Remove unneeded heap.h,
where appropriate, throughout.  Remove unneeded exceptions.h, where
appropriate, throughout.  Remove unneeded perprocess.h, where appropriate,
throughout.
2002-05-25 02:22:50 +00:00
Christopher Faylor 505f9ba17a Revert erroneous checkin. 2001-11-26 20:21:27 +00:00
Christopher Faylor 94c0e197f0 * Makefile.in (libcygwin.a): Use ar commands to build libcygwin.a since adding
an archive doesn't work the way we want it to.
2001-11-26 20:20:42 +00:00
Christopher Faylor 697b8c0c32 * fhandler_console.cc (fhandler_console::read): Revert 2001-10-23 change to
only honor keydown events.
2001-11-12 17:06:50 +00:00
Christopher Faylor a9f20457f3 * Makefile.in: Only build testsuite directory on first 'make check'.
* configure.in: Remove testsuite from SUBDIRS.
* configure: Regenerate.
2001-10-24 21:56:54 +00:00
Christopher Faylor a0626ebe27 Ensure that all fhandler_*::read definitions are __stdcall throughout.
* fhandler.cc (fhandler_base::set_inheritance): Be more defensive in debugging
code.
* fhandler.h: Adjust regparms throughout to reflect passing 'this' parameter.
* fhandler_console.cc (fhandler_console::read): Remove unneeded test.  Only
honor "key down" events.
* miscfuncs.cc (strcasestr): Reorganize for efficient code use.
(check_null_empty_str_errno): Ditto.
(__check_null_invalid_struct_errno): Ditto.
(__check_invalid_read_ptr_errno): Ditto.
* syscalls.cc (_read): Return 0 when length == 0, as per Single UNIX
Specification.
2001-10-24 04:16:45 +00:00
Christopher Faylor e7e231e531 Remove 'cb' parameter and modify fhandler_* constructors throughout.
* dtable.cc (dtable::build_fhandler): Remove debugging output which uses 'cb'.
* exec.cc (execvp): New function.
(execvpe): Ditto.
* fhandler.cc (fhandler_base::fhandler_base): Use constructor initialization.
* fhandler.h (fhandler_tty_common::fhandler_tty_common): Ditto.
* fhandler_clipboard.cc (fhandler_dev_clipboard::fhandler_dev_clipboard):
Ditto.
* fhandler_console.cc (fhandler_console::fhandler_console): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Ditto.
* fhandler_serial.cc (fhandler_serial::fhandler_serial): Ditto.
* fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Ditto.
(fhandler_tty_slave::fhandler_tty_slave): Ditto.
(fhandler_pty_master::fhandler_pty_master): Ditto.
* fhandler_windows.cc (fhandler_windows::fhandler_windows): Ditto.
2001-10-22 18:39:22 +00:00
Christopher Faylor 0476bae576 * fhandler_dsp.cc (fhandler_dsp::ioctl): Return 0 for successful
SNDCTL_DSP_GETBLKSIZE operation.  Remove obsolete 'name' arg from fhandler_*
constructors throughout.
* winsup.h (winsock_active): New macro.
(winsock2_active): Ditto.
* autoload.cc (wsock_init): Use new macros to decide if winsock or winsock2 is
loaded.
(nonexist_wsock32): Dummy function to force winsock load.
(nonexist_ws2_32): Dummy function to force winsock2 load.
* fhandler.h (fhandler_socket::fstat): Declare new method.  Currently unused.
* fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Check that
winsock2 is active before trying WSADuplicateSocketA.
(fhandler_socket::fixup_after_fork): Add extra check for winsock2_active.
Otherwise use iffy procedures for Windows 95.
(fhandler_socket::fixup_after_exec): Add debugging.
(fhandler_socket::dup): Add debugging.
(fhandler_socket::fstat): New method.
(fhandler_socket::set_close_on_exec): Attempt to perform iffy stuff on Windows
95.
* errno.cc (_sys_nerr): Work around compiler strangeness.
* pinfo.cc (winpids::add): Add extra element at end of allocated array for
setting to NULL.
(winpids::enumNT): Ditto.
(winpids::init): Don't modify pidlist if it hasn't been allocated
(possibly due to malloc problem).
2001-10-13 17:23:35 +00:00
Christopher Faylor bc6ed54986 * autoload.cc (wsock_init): Reorganize slightly to accomodate a new compiler. 2001-10-13 01:35:15 +00:00
Christopher Faylor 8af0f81d52 * dcrt0.cc (dll_crt0_1): Don't close hexec_proc if it is NULL.
* fork.cc (vfork): Add debugging statements.
* path.cc (get_device_number): Make static.  Rewrite to inspect both unix and
windows paths.
(get_raw_device_number): Just check for parts of raw device that we care about.
(get_devn): New function, pulled from get_device_number.
(win32_device_name): Accomodate arg changes to get_device_number.
(mount_info::get_device_number): Call get_device_number on translated Windows
path.
* spawn.cc (spawn_guts): Don't treat P_VFORK differently from P_NOWAIT.  Add
handle to child's shared region to child so that it will be preserved if the
parent goes away.
* fhandler.h: Throughout, simplify to one open method for all fhandler classes,
requiring a path_conv first element.
* fhandler.cc (fhandler_base::open): Remove obsolete method.  Generalize to
require path_conv * as first argument.
(fhandler_disk_file::open): Remove obsolete method.
(fhandler_disk_file::open): Use path_conv pointer rather than reference.
* fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Use new open method.
(fhandler_dev_clipboard::open): Accomodate new argument for open methods.
* fhandler_console.cc (fhandler_console::open): Ditto.
(fhandler_console::dup): Use new open method.
(fhandler_console::fixup_after_fork): Ditto.
(fhandler_console::fixup_after_exec): Ditto.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Accomodate new argument for open
methods.
* fhandler_floppy.cc (fhandler_dev_floppy::open): Ditto.
* fhandler_mem.cc (fhandler_dev_mem::open): Ditto.
* fhandler_random (fhandler_dev_random::open): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Ditto.
* fhandler_serial.cc (fhandler_serial::open): Ditto.
* fhandler_tape.cc (fhandler_dev_tape::open): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
(fhandler_pty_master::open): Ditto.
* fhandler_windows.cc (fhandler_windows::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Accomodate new
argument for open methods.
* syscalls.cc (_open): Ditto.
(stat_worker): Ditto.
2001-10-04 02:34:20 +00:00
Christopher Faylor 47063f00e4 Add "path.h" include throughout, where needed. Use new path_conv methods and
operators to simplify testing for directory and attributes, throughout.
* path.h (path_conv::exists): New method.
(path_conv::has_attribute): Ditto.
(path_conv::isdir): Ditto.
(path_conv::DWORD &): New operator.
(path_conv::int &): Ditto.
* dir.cc (rmdir): Eliminate a goto.
* dtable.cc (dtable::build_fhandler): Accept opt and suffix info for
path_conv.check.  Return fh == NULL on path_conv error.  Pass unit to set_name
as appropriate.
(dtable::reset_unix_path_name): New method.
* dtable.h (dtable): Declare new method.  Reflect arg changes to
build_fhandler.
* fhandler.cc (fhandler_disk_dummy_name): Eliminate.
(fhandler_base::set_name): Expect paths to be NULL.  Build unix_path_name from
win32_path_name when it is a device.
(fhandler_base::reset_unix_path_name): New method.
(fhandler_base::raw_read): Report EISDIR when ERROR_INVALID_FUNCTION or
ERROR_INVALID_PARAMETER and reading a directory.
(fhandler_disk_file::fstat): Don't call stat_dev since we should now never be
calling fhandler_disk_file methods with devices.
(fhandler_base::fhandler_base): Clear {unix,win32}_path_name.
(fhandler_base::~fhandler_base): Always free {unix,win32}_path_name.
(fhandler_disk_file::fhandler_disk_file): Remove set_no_free_names kludge.
(fhandler_disk_file::open): Ditto.
* fhandler.h (fhandler_base::no_free_names): Eliminate.
(fhandler_base::set_no_free_names): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Don't set
unix_path_name here.
* path.cc (fchdir): Lock fd table throughout.  Use new
dtable::reset_unix_path_name method to reset path.
* syscalls.cc (stat_worker): Reorganize to always call fstat method.  Pass
path_conv method to fhandler_*::open.
(chroot): Elminate a goto.
2001-10-01 04:10:07 +00:00
Corinna Vinschen ba94682838 * Makefile.in: Build wincap.o.
* wincap.cc: New file.
        * wincap.h: Ditto.
        * autoload.cc: Add dynamic load statement for `CreateHardLinkA'.
        * dcrt0.cc (os_being_run): Eliminated.
        (osname): Ditto.
        (iswinnt): Ditto.
        (set_os_type): Ditto.
        (dll_crt0_1): Call wincap.init() instead of set_os_type().
        (_dll_crt0): Ditto.
        * environ.cc (set_chunksize): New function.
        (parse_thing): `forkchunk' setting now invokes function `set_chunksize'.
        * fork.cc (chunksize): Eliminated. Moved to be member of wincap.
        * host_dependent.h: Removed.
        * syscalls.cc (_link): Try using `CreateHardLinkA' first, if available.
        * cygheap.cc, dcrt0.cc, delqueue.cc, dir.cc,
        environ.cc, fhandler.cc, fhandler.h, fhandler_console.cc,
        fhandler_mem.cc, fork.cc, mmap.cc, net.cc, pinfo.cc, pinfo.h,
        security.cc, syscalls.cc, sysconf.cc, syslog.cc, thread.cc,
        times.cc, tty.cc, uinfo.cc, uname.cc, winsup.h: Use new wincap
        capability check throughout.
        * winsup.h: Include wincap.h. Eliminate extern declarations of
        `os_being_run' and `iswinnt'. Eliminate `os_type" definition.
        * include/cygwin/version.h: Bump version to 1.3.4.
2001-09-12 17:46:37 +00:00
Christopher Faylor 1ff9f4b937 * cygheap.h (init_cygheap): Move heap pointers here.
* include/sys/cygwin.h (perprocess): Remove heap pointers.
* dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff.
(_dll_crt0): Don't initialize heap pointers.
(cygwin_dll_init): Ditto.
(release_upto): Use heap pointers from cygheap.
* heap.h: Ditto.
* fork.cc (fork_parent): Ditto.  Don't set heap pointers in ch.
(fork_child): Remove obsolete sigproc_fixup_after_fork.
* shared.cc (memory_init): Reorganize so that cygheap initialization is called
prior to regular heap since regular heap uses cygheap now.
* sigproc.cc (proc_subproc): Eliminate zombies allocation.
(sigproc_init): Move zombies alloation here.  Don't free up array on fork, just
reuse it.
(sigproc_fixup_after_fork): Eliminate.
* sigproc.h: Ditto.
* include/cygwin/version.h: Reflect change to perprocess structure.
2001-09-07 21:32:07 +00:00
Christopher Faylor 57c89867f5 Move appropriate variables to NO_COPY segment, throughout. 2001-09-06 05:17:22 +00:00
Corinna Vinschen 29ebba7050 2001-09-04 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
* fhandler_console.cc (fhandler_console::char_command): Save the cursor
        position relative to the top of the window.
        * fhandler_cc (fhandler_console::write): Ditto.
2001-09-04 10:45:54 +00:00
Christopher Faylor 300624d4f3 * fhandler_console.cc (get_tty_stuff): Don't initialize shared memory console
area if it is already initialized.
* fhandler_termios.cc (fhandler_termios::tcsetpgrp): Augment debugging info.
2001-08-07 05:15:59 +00:00
Christopher Faylor e5ba4c060e Throughout, change check for running under Windows NT to 'iswinnt'.
* dcrt0.cc (set_os_type): Set 'iswinnt' appropriately.
* cygheap.cc (init_cheap): Revert to using VirtualAlloc for allocating cygheap.
(cygheap_setup_for_child_cleanup): New function.  Standard function to call
after calling CreateProcess to cleanup cygheap info passed to child.
(cygheap_fixup_in_child): Copy cygheap from shared memory into allocated space
under Windows 9x or if can't relocate shared space under NT.
* cygheap.h: Declare new function.
* spawn.cc (spawn_guts): Use cygheap_fixup_in_child.
* fork.cc (fork_parent): Ditto.
* winsup.h: Declare iswinnt.
2001-08-04 21:10:52 +00:00
Christopher Faylor 6b91b8d53b Throughout, reorganize header file inclusion to put security.h prior to
fhandler.h.
* fhandler.h (fhandler_base::get_inheritance): New method.
* fhandler_socket.cc (fhandler_socket::create_secret_event): Use proper
close-on-exec inheritance when creating.
(fhandler_socket::check_peer_secret_event): Create handle as non-inheritable.
2001-07-26 19:22:24 +00:00
Corinna Vinschen 26da27a5f6 * fhandler_console.cc (fhandler_console::read): Detect AltGr more
robustly on WinNT.
2001-06-22 20:08:06 +00:00
Christopher Faylor 99a5bd2fab * exceptions.cc (sig_handle_tty_stop): Reset PID_STOPPED if not actually
stopping.
* fhandler_console.cc (fhandler_console::fixup_after_fork): Don't set
controlling terminal if just inheriting a handle.
(fhandler_console::fixup_after_exec): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::init): Ditto.
* signal.cc (kill_worker): Set appropriate errno if proc_exists determines that
process does not really exist.
2001-06-16 17:09:19 +00:00
Corinna Vinschen 235661a37f * fhandler_console.cc (fhandler_console::dup): Allocate space for
savebuf on Cygwin heap.
        (fhandler_console::char_command): Ditto. Use correct values for size.
2001-06-05 17:59:46 +00:00
Christopher Faylor 792011508a * cygheap.cc (_cfree): Add regparm attribute.
(_crealloc): Ditto.
* dcrt0.cc (dll_crt0_1): Default to always checking for executable for now.
* dtable.cc (dtable::not_open): Move method.
* dtable.h (dtable): Here.
* exceptions.cc (ctrl_c_handler): Don't expect process group leader to handle a
signal if it doesn't exist.
* fhandler.h (fhandler_base): Make openflags protected.
* localtime.c (tzsetwall): Check for __CYGWIN__ as well as __WIN32__.
* path.cc (path_conv::check): Add some comments.  Change strcat to assignment.
* lib/_cygwin_S_IEXEC.cc (_cygwin_bob__): Eliminate.
* fhandler_tty.cc (fhandler_console::dup): Set controlling terminal if
necessary.
* fhandler_tty.cc (fhandler_tty_slave::dup): Ditto.
2001-05-08 15:16:49 +00:00
Christopher Faylor b98ebf5470 Throughout, change 'tty_attached' to 'real_tty_attached', for clarity.
Throughout, change 'OutputStopped' to 'output_stopped', for consistency.
* dtable.cc (stdio_init): Set controlling tty if not set by stdio opens.
* exceptions.cc (ctrl_c_handler): Avoid special pgid checking if no tty is
associated with the process.
(Suggested by Tim Baker <dbaker@direct.ca>)
* external.cc (fillout_pinfo): Return actual tty number for ctty.
* fhandler_console.cc (get_tty_stuff): Set ctty when shared memory is
allocated.  Accept flags input from open().
(set_console_ctty): New function.
(fhandler_console::open): Pass flags to get_tty_stuff and rely on this function
to set the ctty, if appropriate.
* fhandler_termios.cc (fhandler_termios::set_ctty): Move to tty_min class.
* fhandler_tty.cc (fhandler_tty_slave::open): Use tc field to access
set_ctty().
* tty.h (TTY_CONSOLE): Move to include/sys/cygwin.h.
(tty_min): Add set_ctty class here.
* include/sys/cygwin.h (TTY_CONSOLE): New home here.
* path.cc (symlink_info): Make contents an actual buffer.  Pass more flags to
case_check.
(path_conv::check): Reorganize to do parsing based on posix path rather than
native path.
(symlink_info::check): Expect posix path as input.  Translate to native path
here.  Accept path_conv flags.  Stop parsing if not a symlink regardless of
whether previous path was a symlink.
2001-04-28 23:48:28 +00:00
Christopher Faylor f3ea62a847 Remove trailing underscore from fhandler_base and friends, throughout.
* fhandler.h (fhandler_base::set_open_status): New method.  Stores original
open status.
(fhandler_base::get_open_status): New method.  Retrieves original open status.
(fhandler_base::reset_to_open_binmode): New method.
* fhandler.cc (fhandler_base::open): Save open status.
(fhandler_base::init): Ditto.
* fhandler_clipboard.cc (fhandler_clipboard::open): Ditto.
* fhandler_console.cc (fhandler_console::open): Ditto.
* fhandler_dsp.cc (fhandler_dsp::open): Ditto.
* fhandler_dev_mem.cc (fhandler_dev_mem::open): Ditto.
* fhandler_dev_random.cc (fhandler_dev_random::open): Ditto.
* fhandler_serial.cc (fhandler_serial::open): Ditto.
* fhandler_tty_slave.cc (fhandler_tty_slave::open): Ditto.
* fhandler_tty_master.cc (fhandler_tty_master::open): Ditto.
* fhandler_dev_zero.cc (fhandler_dev_zero::open): Ditto.
* syscalls.cc (setmode): Rework so that 0 mode value causes reversion to open
state.
* fhandler_tty_slave.cc (fhandler_tty_slave::read): Use correct multiplier when
converting from deciseconds to milliseconds.
2001-04-24 02:07:58 +00:00
Christopher Faylor 0381fec68f Throughout, change fdtab references to cygheap->fdtab.
* child_info.h (cygheap_exec_info): Eliminate special fdtab stuff.
* spawn.cc (spawn_guts): Ditto.
* cygheap.cc (cygheap_init): Initialize fdtab, if appropriate.
* cygheap.h (CYGHEAPSIZE): Include size of init_cygheap.
(_cmalloc_entry): Include fdtab here.
* dtable.h (dtable): Declare/define new methods.
* dtable.cc (dtable::vfork_child_fixup): New method.
(dtable::fixup_after_exec): Remove unneeded extra arguments.
* dcrt0.cc (dll_crt0_1): Ditto.
* environ.cc (getwinenv): Use case sensitive comparison.
(winenv): Make a copy of environment cache to avoid realloc problems when
duplicate environment variables exist in the environment.  (From Egor Duda)
* net.cc (cygwin_socket): Revert Apr 14 change.
* include/sys/file.h: Protect against previous X_OK definition.
* passwd.cc: Eliminate passwd_sem throughout.
* security.cc: Ditto.
* cygwin.din: Export New functions.
* passwd.cc (read_etc_passwd): Make race safe.
(getpwuid_r): New function.
(getpwnam_r): New function.
2001-04-18 21:10:15 +00:00
Christopher Faylor aa970c616c * Makefile.in: Put -lgcc last in list of libraries, since stdc++ library needs
it.
* cygwin.din: Remove obsolete "__empty" export.
* exceptions.cc (call_signal_handler_now): Force inclusion of function even
when -finline-functions is specified.
* sigproc.h: Remove obsolete call_signal_handler declaration.
* fhandler_console.cc (cp_get_internal): New function.
(cp_convert): New function.
(con_to_str): New function.
(str_to_con): New function.
(fhandler_console::read): Replace OemToCharBuff with con_to_str.
(fhandler_console::write_normal): Replace CharToOemBuff with str_to_con.
2001-04-09 00:44:25 +00:00
Corinna Vinschen 70afbaae17 * fhandler.h (class fhandler_console): Add members `insert_mode'.
* fhandler_console.cc (fhandler_console::dup): Duplicate `insert_mode'.
        (fhandler_console::fhandler_console): Initialize `insert_mode'.
        fhandler_console::char_command): Add terminal capabilities
        "enter insert mode" = \E[4h and "exit insert mode" = \E[4l.
        Care for insert mode on terminal capability "repeat char" = \E[x;yb.
        (fhandler_console::write_normal): Care for insert mode before writing
        to the console.
        (array keytable): Add keymapping for modified cursor and control
        block keys (xterm like).
2001-03-31 09:19:32 +00:00
Corinna Vinschen f42da31ad6 * fhandler.h (class fhandler_console): Add members `savebufsiz' and
`savebuf' to allow save/restore of screen.
        * fhandler_console.cc (fhandler_console::dup): Duplicate savebuf.
        (fhandler_console::fhandler_console): Initialize `savebufsiz' and
        `savebuf'.
        (fhandler_console::char_command): Add terminal capabilities
        "save screen content" = \E[?47h and "restore screen content" = \E[?47l.
2001-03-30 11:10:13 +00:00
Christopher Faylor 0b30bad456 * fhandler_console.cc (fhandler_console::set_default_attr): Update console
color attributes on tty reset.
2001-03-22 18:19:00 +00:00
Egor Duda 79409dc0a2 * fhandler.h (fhandler_termios::fhandler_termios): Enable fixup
after fork.
* fhandler_console.cc (fhandler_console::fhandler_console): Fixup
after fork is now enabled in the base class constructor.
2001-03-12 20:39:40 +00:00
Corinna Vinschen 7cdc9feea1 * autoload.c (cygwin_premain0): Add missing parameter.
* binmode.c (cygwin_premain0): Ditto.
        * textmode.c (cygwin_premain0): Ditto.

Patch contributed by Jason Tiller <jtiller@sjm.com> :
        * auto_load.cc: Add "GetKeyboardLayout" entry in the list of
        Win32 User32.DLL exports to provide.
        * fhandler.h (class fhandler_console): Add meta_mask private
        member to remember which keystroke modifiers should generate
        META.
        * fhandler_console.cc (fhandler_console::read): Modify code that
        tests a keystroke for a META-escaped key to use the 'meta_mask'
        variable.
        (fhandler_console::fhandler_console): Add definition for
        variable "meta_mask" used to determine if a keystroke should be
        preceded by META in the client console stream.  Set meta_mask
        based on whether or not user's keyboard language is English -
        non-English keyboards pass AltGr (right <ALT>) unmolested,
        whereas English keyboards now interpret left- and right-<ALT>
        as META.
2001-03-06 12:05:45 +00:00
Christopher Faylor 95a8465ba0 * dlopen.c (dlopen): Return NULL when name is NULL (suggested by
chrisiasci@aol.com).
* cygwin.din: Add a new, internally used export - _check_for_executable.
* dcrt0.cc (dll_crt0_1): Set _check_for_executable for older binaries.  Pass
user_data to premain functions.
* fhandler.cc (fhandler_disk_file::open): Only check for executable if the
linked program is intereested in the executable bit.
(fhandler_disk_file::check_execable_p): Delete.
* fhandler.h (executable_states): New enumeration of various states of
executable bit caring.
(fhandler_base::set_execable_p): New method.
* fhandler_termios.cc (fhandler_termios::line_edit): Flag when a signal has
been sent to the tty.  Return -1 when this is so.
* fhandler_console.cc (fhandler_console::read): Return -1 when signal sending
character encountered.
* path.cc (path_conv::check): Record when path refers to a disk device.  Move
executable extension check here.
(check_sysfile): Accomodate new EXEC path states.
(has_suffix): Remove.
(next_suffix): Remove.
(class suffix_scan): New clas.
(suffix_scan::has): New method.
(suffix_scan:next): New method.
(symlink_info::check): Use suffix_scan method to control for scanning for
suffixes.
* path.h (path_conv::exec_state): New method.
* perprocess.h: Make "C" friendly.
* include/cygwin/version.h: Define CYGWIN_VERSION_CHECK_FOR_S_IEXEC.  Bump
CYGWIN_VERSION_API_MINOR.
* include/sys/cygwin.h: Change premain declarations.
* winsup.h: Move __cplusplus test to after builtin defines.
2001-03-05 06:28:25 +00:00
Christopher Faylor 0312ede431 *** empty log message *** 2001-03-03 03:56:34 +00:00
Egor Duda a53136cc46 * fhandler.h (class fhandler_console): Make all variables that
describe "state" of console to be members of fhandler_console.
default_color is now the color which is set when console recieves
reset command.
* fhandler_console.cc (fhandler_console::fhandler_console): Turn
mouse handling and raw keyboard mode off by default. Initialize
state information.
* fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New
function.
* fhandler_console.cc (fhandler_console::set_default_attr): New
function. Reset console attributes to default values.
* fhandler_console.cc (fhandler_console::open): Reset attributes.
* fhandler_console.cc (fhandler_console::get_win32_attr): New function.
Calculate win32-style console attribute based on terminal attributes.
* fhandler_console.cc (fhandler_console::set_cursor_maybe): Use
member variable.
* fhandler_console.cc (fhandler_console::read): If in raw-win32
keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK
sequences.
* fhandler_console.cc (fhandler_console::dup): Copy all state
information to the dup()ed handle.
* fhandler_console.cc (fhandler_console::scroll_screen): Use current
fill-in	attribute.
* fhandler_console.cc (fhandler_console::clear_screen): Ditto.
* fhandler_console.cc (fhandler_console::char_command): Check if we
saw '?' symbol by member variable. Set terminal	attributes on \033[Xm
commands. \033[24m - turn off underline mode, \033[27m - turn off
reverse mode, \033[39m - restore default foreground color.
\033[49m - restore default background color. \033[2000h - turn on raw
keyboard mode, \033[2000l - turn off raw keyboard mode.
* fhandler_console.cc (fhandler_console::write): Set attribues to
default values on reset command.
2001-02-27 09:14:35 +00:00
Christopher Faylor 8f8e7442bb * fhandler_console.cc (fhandler_console::char_command): Ignore unknown
rendition codes in \033[xx;yym control sequences
2001-02-14 22:00:09 +00:00
Christopher Faylor 2a6fc028ba Throughout, change 'cygwin_shared.mount' to 'mount_table'.
* child_info.h (child_info): Move shared_h, console_h to cygheap.  Add mount_h.
* cygheap.h (init_cygheap): Add shared_h, console_h.
* cygheap.cc (init_cheap): Initialize heap at a fixed location after the shared
memory regions.  Initialize cygheap->user name here.
* dcrt0.cc (dll_crt0_1): Call getpagesize () to initialize constants.  Remove
cygheap_init since it is done in shared_init now.
(_dll_crt0): Initialize mount_h, remove shared_h and console_h initialization.
* fhandler_console.cc (console_shared_h): Eliminate.
(get_tty_stuff): Use cygheap->console_h rather than console_shared_h.
* heap.cc (heap_init): Use page size constant calculated earlier in
initialization.
* shared.cc: Eliminate cygwin_shared_h.  Add cygwin_mount_h.
(mount_table_init): New function for initializing a user mount table.
(open_shared_file_map): Use constant for shared memory region.  Initialize
cygheap and mount table here.
(open_shared): Improve debugging output.
(shared_info::initialize): Eliminate call to mount.init.
(shared_terminate): Use cygheap->shared_h.  Close cygwin_mount_h.
(open_shared_file_map): Eliminate.
* shared_info.h (mount_info): Add a version field.
(shared_align_past): New macro for calculating location for shared memory
regions.
* sigproc.cc (init_child_info): Eliminate shared_h, console_h.
* spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different user.
* syscalls.cc (system_info): New global holding system memory defaults.
(getpagesize): Use system_info.
* uinfo.cc (internal_getlogin): Only fill in user name if nonexistent.
* winsup.h: Declare system_info.
* passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than retrieving
the name again.
2001-01-28 05:51:15 +00:00
Christopher Faylor a7cde2b98a * autoload.cc (LoadDLLinitfunc): Remove debugging statement.
* exceptions.cc (sig_handle_tty_stop): Move setting of PID_STOPPED to earlier
in interrupt.
((interrupt_setup): i.e., here.
(sig_handle): Don't queue multiple SIGSTOPS.
* fhandler.h (bg_check_types): Enumerate return value of bg_check for clarity.
* signal.cc (kill_pgrp): Minor cleanup.
* fhandler_termios.cc (fhandler_termios::bg_check): Use enumerated type for
function return.  Don't raise signal if a signal is already queued.
* fhandler_console.cc (fhandler_console::read): Use enumerated return type for
bg_check.
* select.cc: Ditto, throughout.
* read.cc: Ditto, throughout.
* termios.cc: Ditto, throughout.
(_read): YA interrupt detect simplification.
* wait.cc (wait4): Ditto.
2001-01-17 14:57:09 +00:00
Christopher Faylor 077ec4cb37 * pinfo.cc (codepage_init): Move function.
* environ.cc (codepage_init): To here.
* exceptoins.cc (SIG_NONMASKABLE): Remove SIGCONT from consideration since it
is supposed to be maskable.
* signal.cc (sigaction): Ditto.
* sigproc.cc (wait_sig): Ditto.
* winsup.h: Eliminate global declaration of codepage_init.
2001-01-08 04:02:02 +00:00
Christopher Faylor c79ec95060 * fhandler_console.cc (fhandler_console::read): Restore missing test for code
page before doing OemToCharBuff.
2001-01-03 14:45:47 +00:00
Christopher Faylor 085ec17c5d * fhandler_console.cc (read): Add support for xterm-style mouse event
reporting.
(fhandler_console::char_command): Honor mouse events.
(fhandler_console::open): Enable mouse input events.
(fhandler_console::input_tcsetattr): Ditto.
* select.cc (peek_console): Add check for mouse events.
2000-12-16 03:11:02 +00:00
Christopher Faylor 80d0051c37 * fhandler.h (fhandler_console): Add additional argument to char_command
method.
* fhandler_console.cc (fhandler_console::read): Revert previously misapplied
patch.
(fhandler_console::char_command): Add a second argument.
(fhandler_console::write): Recognize when a '?' is found after a <esc>[.
2000-12-15 04:42:20 +00:00
Christopher Faylor ee1d77e4b7 * autoload.cc: Autoload CharToOemA.
* dcrt0.cc (dll_crt0_1): Translate command line to OEM if current codepage is
OEM.
* environ.cc: Add new option 'codepage' to CYGWIN environment variable.
* fhandler_clipboard.cc (fhandler_clipboard::read): Read clipboard in OEM mode
if current codepage is OEM.
* fhandler_console.cc (fhandler_console::read): Only translate console input if
current codepage is ANSI.
* fhandler_console.cc (fhandler_console::write_normal): Translate output data
if current codepage is ANSI.
* pinfo.cc (codepage_init): New function.  Setup current codepage from CYGWIN
environment variable and set codepage for file APIs.
* security.cc (read_sd): Translate file name to it if current codepage is OEM.
* winsup.h: (sys_wcstombs,sys_mbstowcs): Use current codepage for translations
between multibyte and widechar string and vice versa.
2000-12-10 00:45:12 +00:00
Christopher Faylor 307cb8ba82 * path.cc (normalize_win32_path): Check for explicit use of two slashes at the
beginning of a path.  These should be treated specially regardless of whether
they are UNC paths or old-style //a paths.  Avoid adding cwd to a path if the
path already begins with '/'.
2000-12-09 21:31:49 +00:00
Christopher Faylor 5758fdf31d * fhandler_console.cc: New member variable `dwBufferSize' for `info'.
(fillin_info): Set `dwBufferSize' to the size of the console buffer.
(clear_screen): Use width of console buffer to calculate how many spaces to
clear.
2000-11-17 03:01:14 +00:00
Christopher Faylor ad30b4ffca * fork.cc (fork): Set sigframe here, since it can pause for a considerable
amount of time.
* environ.cc (_addenv): Add debugging.
* fhandler.cc: Eliminate unneeded include.
* smallprint.c: Ditto.
2000-10-23 03:35:50 +00:00
Christopher Faylor b0de2aa284 * fhandler.h (fhandler_console): Remove tcsetpgrp.
* fhandler_console.cc (fhandler_console::tcsetpgrp): Eliminate.
* fork.cc (fork_parent): Avoid returning same pid twice in a row regardless of
OS.
* pinfo.cc (pinfo::init): Rename create argument to flags and treat it as such.
* signal.cc (set_sigcatchers): New function.
(signal): Use set_sigcatchers to increment or decrement sigcatcher tracker.
(sigaction): Ditto.  Add debugging output.
* spawn.cc (spawn_guts): Always quote first argv[0] argument when it's a
COMSPEC shell.
2000-10-21 04:53:49 +00:00
DJ Delorie 2556e737ec * Makefile.in: add miscfuncs.cc
* miscfuncs.cc: new, miscellaneous functions
* winsup.h: define table-driven tolower/toupper
* environ.cc: use them
* fhandler_console.cc: ditto
* fhandler_termios: ditto
* path.cc: ditto
(strncasematch, strcasematch, strcasestr): move to miscfuncs.cc
2000-10-19 03:12:44 +00:00
Christopher Faylor ec300c9979 * errno.cc (seterrno_from_win_error): Fix debugging output.
* fhandler.cc (fhandler_base::fstat): Move to inline method in fhandler.h.
(fhandler_base::set_io_handle): Ditto.
* fhandler.h (fhandler_base): Make some methods inline.
* fhandler_console.cc (fhandler_console::write_normal): Make buffer larger.
* sigproc.h (sigframe::sigframe): Actually use set ebp parameter correctly.
* spawn.cc (spawn_guts): Set dwProcessId when exec'ing.  Just exit immediately
after reparenting.
* syscalls.cc: Sprinkle sigframe stuff throughout.
* wait.cc (wait4): Set signal frame here.
* dcrt0.cc (__api_fatal): Don't rely on small_printf to display errors.  Always
display problems to the console, if possible.
2000-10-12 04:38:29 +00:00
Christopher Faylor f0338f545d Break out more header info into separate files. Use appropriate header files
throughout.
* shared.h: Remove.
* cygwin_version.h: New file.
* delqueue.h: New file.
* environ.h: New file.
* host_dependent.h: New file.
* perprocess.h: New file.
* registry.h: New file.
* security.h: New file.
2000-09-08 02:56:55 +00:00
Christopher Faylor 29ac7f89e3 Split out tty and shared_info stuff into their own headers and use throughout.
Include sys/termios.h for files which need it.
* tty.h: New file.
* shared_info.h: New file.
* fhandler.h: Move inline methods that rely on tty stuff to
fhandler_console.cc.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Set
output_done_event immediately after reading data to speed up tty output
processing.
(process_output): Set write_error to errno or zero.
(fhandler_tty_slave::write): Check previous write error prior to writing to
slave end of pipe.  This allows tty output to be slightly less synchronous.
* fhandler_console.cc (fhandler_console::tcsetpgrp): Moved here from
fhandler.h.
(fhandler_console::set_input_state): Ditto.
2000-09-07 16:23:51 +00:00
Christopher Faylor b0e82b74fb * Makefile.in: Add cygheap.o.
* child_info.h: Add specific exec class.
* cygheap.h: New file.  Contains declarations for cygwin heap.
* cygheap.cc: New file.  Implements cygwin heap functions.
* dcrt0.cc (quoted): Simplify due to new method for passing arguments between
cygwin programs.
(alloc_stack_hard_way): Attempt to handle overlapped stack.
(dll_crt0_1): Move child_info processing here.  Accomodate new method for
passing arguments between cygwin programs.  Initialize cygwin heap.  Establish
__argc and __argv variables.
(_dll_crt0): Move most of child_info processing to dll_crt0_1.
(cygwin_dll_init): Remove duplication.
* dtable.cc (dtable::extend): Allocate dtable using cygwin heap.
(dtable::build_fhandler): Ditto for fhandler type being constructed.
(dtable::dup_worker): Free new fhandler from cygwin heap on error.
(dtable::select_*): Don't assume that this == fdtab.
(dtable::linearize_fd_array): Delete.
(dtable::delinearize_fd_array): Delete.
(dtable::fixup_after_exec): New file.
(dtable::vfork_child_dup): Use cygwin heap.
(dtable::vfork_parent_restore): Ditto.
* dtable.h: Remove obsolete methods.  Add new method.
* environ.cc (posify): Eliminate already_posix parameter and logic.
(envsize): New function.
(_addenv): Use envsize.
(environ_init): Accept an argument pointing to an existing environment list.
If supplied, allocate space for this in the the program's heap.
* fhandler.cc (fhandler_base::operator =): Move here from fhandler.h.  Use
cygwin heap to allocate filenames.
(fhandler_base::set_name): Allocate/free names from cygwin heap.
(fhandler_base::linearize): Delete.
(fhandler_base::de_linearize): Delete.
(fhandler_base::operator delete): Free from cygwin heap.
(fhandler_base::~fhandler_base): Ditto.
* fhandler.h: Accomodate elimination of *linearize and other changes above.
* fhandler_console.cc (fhandler_console::fixup_after_exec): Rename from
de_linearize.
* heap.h: New file.
* fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Use cygwin heap for
name.  fhandler_tty::fixup_after_exec): Rename from de_linearize.
* fork.cc (fork): Call cygheap_fixup_in_child.
* heap.cc: Use declarations in heap.h.
* malloc.cc: Sprinkle assertions throughout to catch attempts to free/realloc
something from the cygwin heap.
* path.cc: Throughout, eliminate use of per-thread cache for cwd.  Use cwd_*
functions rather than cwd_* variables to access cwd_win32 and cwd_posix.
(cwd_win32): New function.
(cwd_posix): New function.
(cwd_hash): New function.
(cwd_fixup_after_exec): New function.
* path.h: Accomodate path.cc changes.
* pinfo.cc (pinfo_init): Accept a pointer to an environment table.  Pass this
to environ_init.  Eliminate old 'title' tests.
* pinfo.h: Accomodate above change in argument.
* spawn.cc (struct av): New method for building argv list.
(av::unshift): New method.
(spawn_guts): Allocate everything that the child process needs in the cygwin
heap and pass a pointer to this to the child.  Build argv list using new
method.  Eliminate delinearize stuff.
* thread.h: Eliminate _cwd_win32 and _cwd_posix buffers.
* winsup.h: Eliminate obsolete functions.  Add envsize() declaration.
2000-09-03 04:16:35 +00:00
Christopher Faylor bccd5e0d85 * winsup.h: Eliminate inclusion of most of the cygwin .h files. Use .h files
only in sources which require them.
* Makefile.in: Generate dependencies with -MD option.
2000-08-22 05:10:20 +00:00