* fhandler.h (fhandler_tty_slave::fch_open_handles): Declare private.
(fhandler_tty_slave::fch_close_handles): Ditto.
(fhandler_tty_slave::cygserver_attach_tty): Drop declaration.
(fhandler_tty_slave::fstat): Declare public.
(fhandler_tty_slave::fchmod): Declare public.
(fhandler_tty_slave::fchown): Declare public.
(class fhandler_pty_master): Add master_ctl handle.
(fhandler_pty_master::pty_master_thread): Declare public.
* fhandler_termios.cc (fhandler_termios::tcinit): If the process
is started from a non-Cygwin process, make it tty process group
leader.
* fhandler_tty.cc: Throughout accommodate additional security related
arguments in calls to functions creating or opening objects.
(close_maybe): Move to start of file to reuse it
in other methods.
(struct pipe_request): Define.
(struct pipe_reply): Define.
(fhandler_tty_slave::open): Throughout, try to open synchronization
objects with MAXIMUM_ALLOWED permissions. Drop call to cygserver.
Try to duplicate pipe handles via master_ctl pipe if duplicating
directly doesn't work.
(fhandler_tty_slave::cygserver_attach_tty): Remove.
(fhandler_tty_slave::init): Close unused incoming pipe handle.
(fhandler_pty_master::close): Send exit message to master control
thread and close master_ctl handle.
(fhandler_pty_master::pty_master_thread): New method, implementing the
master control thread.
(pty_master_thread): Static helper to start master control thread.
(fhandler_pty_master::setup): Simplify creating pipe inheritance.
Make sure we're the one creating the input_available_event. Add
comment to explain why. Create master_ctl pipe and start master
control thread. Close master_ctl handle in case of error.
* security.cc (alloc_sd): Add code to handle tty objects. Add comments
to explain what exactly is required.
(get_object_sd): New function.
(get_object_attribute): New function.
(create_object_sd_from_attribute): New function.
(set_object_sd): New function.
(set_object_attribute): New function.
(set_file_attribute): Change attribute type to mode_t.
* security.h (set_file_attribute): Change attribute type to mode_t.
(get_object_sd): Declare.
(get_object_attribute): Declare.
(create_object_sd_from_attribute): Declare.
(set_object_sd): Declare.
(set_object_attribute): Declare.
* tty.cc (tty::slave_alive): Implement directly instead of via alive.
(tty::exists): Open mutex handle with READ_CONTROL access.
(tty::alive): Remove.
(tty::open_output_mutex): Convert to inline method.
(tty::open_input_mutex): Ditto.
(tty::open_mutex): Take additional ACCESS_MASK parameter for the
mutex open access mask.
(tty::open_inuse): New method.
(tty::create_inuse): Take PSECURITY_ATTRIBUTES parameter. Drop fmt
name parameter. Always create TTY_SLAVE_ALIVE event.
(tty::get_event): Take additional PSECURITY_ATTRIBUTES parameter for
CreateEvent.
* tty.h (class tty): Change declarations according to aforementioned
changes.
(tty::open_output_mutex): Implement as inline method.
(tty::open_input_mutex): Ditto.
* miscfuncs.cc (yield): Rename from low_priority_sleep. Remove all of the
logic which called Sleep() and just use SwitchToThread.
* miscfuncs.h (yield): Rename from low_priority_sleep.
(SLEEP_0_STAY_LOW): Delete unused define.
* shared.cc (memory_init): Move heap_init() call directly after shared memory
initialization to more closely mimic long-standing program flow.
* tty.cc (tty_list::terminate): Replace call to low_priority_sleep with Sleep.
(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.
where appropriate.
* globals.cc: New file for generic global variables.
* mkglobals_h: New file to generate globals.h.
* mkstatic: New Script used to build a (currently non-working) static
libcygwin_s.a.
* Makefile.in: Add unused rule to build a non-working libcygwin_s.a.
(DLL_OFILES): Add globals.o. Make all objects rely on globals.h.
(globals.h): New target. Generate globals.h.
* cygtls.h: Honor new CYGTLS_HANDLE define to control when the HANDLE operator
is allowed in _cygtls.
* dcrt0.cc: Move most globals to globals.cc.
* init.cc: Ditto.
* environ.cc (strip_title_path): Remove now-unneeded extern.
* fhandler_serial.cc (fhandler_serial::open): Ditto.
* pinfo.cc: Ditto.
(commune_process): Ditto.
* shared.cc: Ditto.
* glob.cc: Ditto.
* strace.cc: Ditto.
* exceptions.cc: Define CYGTLS_HANDLE before including winsup.h.
* path.cc (stat_suffixes): Move here.
* security.h: Add forward class path_conv declaration.
* smallprint.cc (__small_vsprintf): Make a true c++ function.
(__small_sprintf): Ditto.
(small_printf): Ditto.
(console_printf): Ditto.
(__small_vswprintf): Ditto.
(__small_swprintf): Ditto.
* spawn.cc (spawn_guts): Remove _stdcall decoration in favor of regparm.
(hExeced): Move to globals.cc
* strfuncs.cc (current_codepage): Ditto.
(active_codepage): Ditto.
* sync.cc (lock_process::locker): Move here from dcrt0.cc.
* syscalls.cc (stat_suffixes): Move to path.cc.
* tty.cc (tty::create_master): Uncapitalize fatal warning for consistency.
* winsup.h: Include globals.h to declare most of the grab bag list of globals
which were previously defined here.
* mount.h: Move USER_* defines back to shared_info.h.
* speclib: Force temporary directory cleanup.
* 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.
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
(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.
* fhandler.h (fhandler_base::fixup_after_exec): Make non-inline.
(fhandler_termios::fixup_after_fork): Delete declaration.
(fhandler_termios::fixup_after_exec): Ditto.
(fhandler_tty_common::inuse): Remove.
(fhandler_tty_common::dup): Delete declaration.
(fhandler_tty_common::fixup_after_fork): Ditto.
(fhandler_tty_slave::fixup_after_exec): Declare new function.
(fhandler_pty_master::dwProcessId): New variable.
(fhandler_pty_master::from_master): Ditto.
(fhandler_pty_master::to_master): Ditto.
(fhandler_pty_master::setup): New function.
(fhandler_pty_master::fixup_after_fork): Ditto.
(fhandler_pty_master::fixup_after_exec): Ditto.
* fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete definition.
(fhandler_termios::fixup_after_fork): Ditto.
* fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master setup
function rather than obsolete tty::common_init. Delete obsolete inuse setting.
(fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here.
(fhandler_tty_slave::open): Change debugging output for clarity. Check for
different things when doing a sanity check on the tty. Reflect the fact that
master_pid now is the cygwin pid rather than the windows pid. Use "arch"
rather than "archetype" for consistency.
(fhandler_tty_slave::close): Close inuse here.
(fhandler_tty_slave::dup): Remove old if 0'ed code.
(fhandler_pty_master::dup): New function. Handles pty master archetype.
(fhandler_pty_master::fhandler_pty_master): Zero pty_master specific fields.
(fhandler_pty_master::open): Implement using archetypes, similar to slave. Use
fhandler_pty_master setup function rather than obsolete tty::common_init.
Don't set inuse.
(fhandler_tty_common::close): Don't deal with inuse. Delete old if 0'ed code.
(fhandler_pty_master::close): Implement using archetypes. Close from_master
and to_master.
(fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag here
since everything uses archetypes now.
(fhandler_tty_common::fixup_after_fork): Delete definition.
(fhandler_tty_slave::fixup_after_exec): Define new function.
(fhandler_pty_master::setup): New function, derived from tty::common_init.
(fhandler_pty_master::fixup_after_fork): New function.
(shared_info.h): Reset SHARED_INFO_CB to reflect new tty size.
* tty.cc (tty_list::terminate): Close individual handles from tty_master.
(tty::master_alive): Delete.
(tty::make_pipes): Ditto.
(tty::common_init): Ditto.
* tty.h (tty::from_slave): Delete.
(tty::to_slave): Ditto.
(tty::common_init): Delete declaration.
(tty::make_pipes): Ditto.
(tty::master_pid): Define as pid_t since it is now a cygwin pid.
* 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.
* 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.
* tty.h: Remove the %d or %x from all cygtty strings.
(tty::open_output_mutex): Only declare.
(tty::open_input_mutex): Ditto.
(tty::open_mutex): New definition.
* fhandlet_tty.cc (fhandler_tty_slave::open): Declare buf with
size CYG_MAX_PATH and replace __small_printf calls by shared_name.
* tty.cc (tty::create_inuse): Ditto.
(tty::get_event): Ditto.
(tty::common_init): Ditto.
(tty::open_output_mutex): New method definition.
(tty::open_input_mutex): Ditto.
(tty::open_mutex): New method.
(fhandler_tty_master::fixup_after_exec): Ditto.
* fhandler_tty.cc (fhandler_tty_master::init): Fix so that children do not
inherit master tty handles.
(fhandler_tty_master::fixup_after_fork): Remove, since it was never used.
(fhandler_tty_master::fixup_after_exec): Ditto.
* pinfo.cc (_pinfo::set_ctty): Increment open_fhs when ctty is set.
* cygheap.cc (cygheap_init): Ditto.
* syscalls.cc (setsid): *Always* call close on opened ctty since the archetype
is associated with the ctty and it counts as an opened handle.
* tty.cc (tty::common_init): Don't protect input/output mutex since it confuses
subsequent fork/execs when CYGWIN=tty.
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.
* cygserver.h: Moved from include/cygwin to here.
* cygserver_ipc.h: Moved from ../cygserver to here.
* cygserver_shm.h: Ditto.
* cygwin.din: Add shmat, shmctl, shmdt and shmget.
* fhandler_tty.cc (fhandler_tty_slave::open): Don't warn about handle
dup'ing if not build with USE_SERVER.
* shm.cc: Include cygerrno.h unconditionally.
(shmat): Set errno to ENOSYS and return -1 if not build with
USE_SERVER.
(shmctl): Ditto.
(shmdt): Ditto.
(shmget): Ditto.
* woutsup.h: Remove.
* include/cygwin/cygserver_process.h: Moved to ../cygserver directory.
* include/cygwin/cygserver_transport.h: Ditto.
* include/cygwin/cygserver_transport_pipes.h: Ditto.
* include/cygwin/cygserver_transport_sockets.h: Ditto.
* include/cygwin/version.h: Bump API minor number.
* 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.
* Makefile.in (LIBSERVER): Define and use.
* configure.in: Set LIBSERVER as appropriate.
* environ.cc: Rename allow_daemon to allow_server. Only recognize when
USE_SERVER is defined.
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.
* autoload.cc (GetSystemTimes): Define new autoload function.
* fhandler_proc.cc (proc_listing): Add cpuinfo and partitions entries.
(fhandler_proc::fill_filebuf): Add PROC_CPUINFO and PROC_PARTITIONS cases.
(format_proc_uptime): Use GetSystemTimes if available.
(read_value): New macro.
(print): New macro.
(cpuid): New function.
(can_set_flag): New function.
(format_proc_cpuinfo): New function.
(format_proc_partitions): New function.
(path_conv::is_lnk_symlink): New function. True if path represents .lnk style
symlink.
* path.cc (check_shortcut): Set PATH_LNK in pflags when appropriate.
(symlink_info::check): Ditto. Remove PATH_LNK from pflags initially.
* syscalls.cc (unlink): Always remove readonly attribute from a symlink
regardless of type.
(link): (from Corinna Vinschen) Allow links to symlinks. Reset attributes on a
symlink after successful link creation.
(chmod): Use is_lnk_symlink where appropriate.
(rename): Ditto.
* tty.cc (create_tty_master): Call GetComputerName instead of
cygwin_gethostname. Set ut_id.
* syscalls.cc (login): Call endutent.
(setutent): Do not seek after a fresh open.
waiting for signals to happen.
* signal.cc (sleep): Force pending signal delivery before sleeping.
(usleep): Ditto.
(signal): Force pending signal delivery before manipulating signal stuff.
(sigprocmask): Ditto.
(kill_worker): Ditto.
(abort): Ditto.
(sigaction): Ditto.
* syscalls.cc (readv): Force pending signal delivery before I/O.
(writev): Ditto.
(open): Ditto.
* net.cc: Ditto, throughout.
* sigproc.cc (sig_dispatch_pending): Deliver any pending signals prior to
returning.
* tty.cc (tty::make_pipes): Increase pipe buffer size.
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.
* cygwin.din (pututline): New exported function.
* syscalls.cc (login): Use pututiline().
(setutent): Open utmp as read/write.
(endutent): Check if utmp file is open.
(utmpname): call endutent() to close current utmp file.
(getutid): Enable all cases, use strncmp() to compare ut_id fields.
(pututline): New.
* tty.cc (create_tty_master): Set ut_pid to current pid.
Assume that they exit via an ExitThread call.
* cygthread.h (cygthread::SetThreadPriority): New function.
(cygthread::zap_h): New function.
* dcrt0.cc (do_exit): Move cygthread::terminate earlier and establish
exit_state guard.
* fhandler.h (fhandler_tty_master::output_thread): Delete.
* fhandler_tty.cc (fhandler_tty_master::init): Set priority for threads via
method. Zap handles when done. Don't treat process_output specially.
(process_output): Call ExitThread directly.
(fhandler_tty_master::fixup_after_fork): Don't worry about output_thread.
(fhandler_tty_master::fixup_after_exec): Ditto.
* sigproc.cc (proc_terminate): Don't detach from hwait_subproc. Just let it
exit.
(sigproc_init): Close thread handle after initialization.
(wait_sig): Use GetCurrentThread() as SetThreadPriority call rather than
*event* handle. Call ExitThread directly on termination.
(wait_subproc): Call ExitThread directly on termination.
* tty.cc (tty_list::terminate): Don't attempt t detach from output_thread.
GNUify non-GNU formatted functions calls throughout.
2002-09-22 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc (with_strerr): Remove macro.
(server_shmmgr::segment_t::~segment_t): Remove calls to with_strerr.
(server_shmmgr::segment_t::attach): Ditto.
(server_shmmgr::new_segment): Ditto.
* shm.cc (with_strerr): Remove macro.
(client_shmmgr::shmdt): Remove calls to with_strerr.
(client_shmmgr::attach): Ditto.
2002-09-21 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/sys/ipc.h: Move to "include/cygwin/ipc.h".
* include/sys/msg.h: Move to "include/cygwin/msg.h".
* include/sys/sem.h: Move to "include/cygwin/sem.h".
* include/sys/shm.h: Move to "include/cygwin/shm.h".
* include/cygwin/ipc.h: New file.
* include/cygwin/msg.h: Ditto.
* include/cygwin/sem.h: Ditto.
* include/cygwin/shm.h: Ditto.
* cygserver_shm.h: Update includes.
* msg.cc: Ditto.
* sem.cc: Ditto.
2002-09-21 Conrad Scott <conrad.scott@dsl.pipex.com>
* safe_memory.h (safe_delete): Make a templated function.
* cygserver.cc (~server_request): Update use of safe_delete.
(main): Ditto.
* cygserver_client.cc (client_request::handle_request): Ditto.
(client_request::make_request): Ditto.
* cygserver_process.cc (~process_cleanup): Ditto.
(process::remove): Ditto.
(process::cleanup): Ditto.
(process_cache::process): Ditto.
* cygserver_shm.cc (server_shmmgr::segment_t::detach): Ditto.
(server_shmmgr::delete_segment): Ditto.
* shm.cc (client_shmmgr::shmdt): Ditto.
* threaded_queue.cc (~threaded_queue): Ditto.
(threaded_queue::worker_loop): Ditto.
2002-08-29 Conrad Scott <conrad.scott@dsl.pipex.com>
* safe_memory.h: Replace #include <new> with an explicit
definition of the placement new operator.
(safe_delete): Remove unnecessary ## operator.
2002-07-28 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc (class server_shmmgr): Remove `cleanup_t'
friend declaration.
(cleanup_t::cleanup_t): Use the segment's shmid as the key rather
than the segment pointer itself.
(cleanup_t::segptr): Remove method.
(cleanup_t::shmid): New method.
(cleanup_t::cleanup): Update for new key value.
(server_shmmgr::find (segment_t *)): Remove method.
* include/cygwin/cygserver_process.h (cleanup_routine::key): Make
method const.
2002-07-27 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver_process.h
(cleanup_routine::_key): New field.
(cleanup_routine::cleanup_routine): Initialise new field with new
argument.
(cleanup_routine::operator==): New method.
(cleanup_routine::key): New method.
(cleanup_routine::cleanup): Make argument non-const.
(process::is_active): New method.
(process::remove): Ditto.
(process::check_exit_code): Rename method.
* cygserver_process.cc (process::add): Reorganize code.
(process::remove): New method.
(process::check_exit_code): Rename method.
(process::cleanup): Use new `process::is_active' method.
(process_cache::process): Ditto.
(process_cache::sync_wait_array): Ditto.
(process_cache::check_and_remove_process): Ditto.
* cygserver_shm.cc (server_shmmgr): Make `cleanup_t' a friend.
(segment_t::detach): Make argument non-const. Remove cleanup
object from client if appropriate.
(cleanup_t::_segptr): Remove field.
(cleanup_t::cleanup_t): Initialise parent explicitly. Remove
field.
(cleanup_t::segptr): New method.
(cleanup_t::cleanup): Add error checking and reporting.
(server_shmmgr::shmdt): Make argument non-const.
(server_shmmgr::find (segment_t *)): New method.
2002-07-27 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver.cc (client_request_shutdown::client_request_shutdown):
Comment out verbose tracing statement.
* cygserver_client.cc
(client_request_get_version::client_request_get_version): Ditto.
(client_request_attach_tty::client_request_attach_tty): Ditto.
* cygserver_shm.cc (client_request_shm::client_request_shm):
Ditto.
2002-07-27 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_transport_pipes.cc (transport_layer_pipes::listen):
Set `_is_listening_endpoint' appropriately.
2002-07-27 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver_transport.h
(transport_layer_base::listen): Change return type.
(transport_layer_base::connect): Ditto.
* include/cygwin/cygserver_transport_pipes.h
(transport_layer_pipes::listen): Change return type.
(transport_layer_pipes::connect): Ditto.
(transport_layer_pipes::_sec_none_nih): Remove unused field.
(transport_layer_pipes::_is_listening_endpoint): New field.
* cygserver_transport_pipes.cc: Synchronize with sockets code.
(transport_layer_pipes::transport_layer_pipes): Initialise new
field. Separate out asserts.
(transport_layer_pipes::listen): Change return type. Add asserts.
(transport_layer_pipes::accept): Add asserts.
(transport_layer_pipes::read): Change conditional to an assert.
Add assert.
(transport_layer_pipes::write): Ditto.
(transport_layer_pipes::connect): Change return type. Change
conditional to an assert. Add asserts. Rationalize error code
slightly.
(transport_layer_pipes::impersonate_client): Add asserts.
* include/cygwin/cygserver_transport_sockets.h
(transport_layer_sockets::listen): Change return type.
(transport_layer_sockets::connect): Ditto.
(transport_layer_sockets::_addr): Change type of field.
(transport_layer_sockets::_addr_len): Ditto.
(transport_layer_sockets::_is_accepted_endpoint): New field.
(transport_layer_sockets::_is_listening_endpoint): Ditto.
* cygserver_transport_sockets.cc
(MAX_CONNECT_RETRY): New constant.
(transport_layer_sockets::transport_layer_sockets): Initialise new
fields. Only initialise the socket address where necessary.
(transport_layer_sockets::listen): Change return type. Rewrite.
(transport_layer_sockets::accept): Add asserts. Add tracing
statements. Use a local variable to hold the accepted address.
(transport_layer_sockets::close): Add tracing statements. Unlink
the UNIX domain socket file as appropriate. Close the socket
cleanly.
(transport_layer_sockets::read): Rewrite method.
(transport_layer_sockets::write): Ditto.
(transport_layer_sockets::connect): Change return type. Rewrite.
* cygserver.cc (server_submission_loop::request_loop): Run the
listening thread at high priority with special handling for
shutdown.
(main): Print the request error code rather than errno in shutdown
request code. Install signal handlers with sigaction(2) to avoid
setting SA_RESTART. Check value of the listen method call, now it
has one.
* cygserver_client.cc (client_request::make_request): Check new
return value on connect method call.
2002-07-27 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver_transport_pipes.h
(cygserver_transport_pipes::_sd): Rename field.
(cygserver_transport_pipes::_sec_none_nih): Ditto.
(cygserver_transport_pipes::_sec_all_nih): Ditto.
(cygserver_transport_pipes::_pipe_name): Ditto.
(cygserver_transport_pipes::_hPipe): Ditto.
(cygserver_transport_pipes::_is_accepted_endpoint): Ditto.
* cygserver_transport_pipes.cc
(transport_layer_pipes::transport_layer_pipes): Rename fields.
(transport_layer_pipes::init_security): Ditto.
(transport_layer_pipes::listen): Ditto.
(transport_layer_pipes::accept): Ditto.
(transport_layer_pipes::close): Ditto.
(transport_layer_pipes::read): Ditto.
(transport_layer_pipes::write): Ditto.
(transport_layer_pipes::connect): Ditto.
(transport_layer_pipes::impersonate_client): Ditto.
(transport_layer_pipes::revert_to_self): Ditto.
* include/cygwin/cygserver_transport_sockets.h
(cygserver_transport_sockets::_fd): Rename field.
(cygserver_transport_sockets::_addr): Ditto.
(cygserver_transport_sockets::_addr_len): Ditto.
* cygserver_transport_sockets.cc
(transport_layer_sockets::transport_layer_sockets): Rename fields.
(transport_layer_sockets::listen): Ditto.
(transport_layer_sockets::accept): Ditto.
(transport_layer_sockets::close): Ditto.
(transport_layer_sockets::read): Ditto.
(transport_layer_sockets::write): Ditto.
(transport_layer_sockets::connect): Ditto.
2002-07-27 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc (with_strerr): Fix use of %p format.
* shm.cc (client_shmmgr::shmat): Ditto.
(client_shmmgr::shmctl): Ditto.
(client_shmmgr::shmdt): Ditto.
(client_shmmgr::attach): Ditto.
2002-07-14 Christopher Faylor <cgf@redhat.com>
* woutsup.h (system_printf): Remove extraneous semicolon from macro
definition.
2002-07-14 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_transport_pipes.cc
(transport_layer_pipes::connect): Use ProtectHandle in DLL code.
(transport_layer_pipes::close): Use ForceCloseHandle in DLL code.
2002-07-13 Nicholas Wourms <nwourms@netscape.com>
* threaded_queue.h (class queue_submission_loop): Correct friend
declaration for GCC 3.1.1.
* include/cygwin/cygserver_process.h (class process): Ditto.
(class process_cache): Ditto.
2002-07-12 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc (server_shmmgr::shmdt): Only call
delete_segment if the segment exists [sic].
2002-07-12 Conrad Scott <conrad.scott@dsl.pipex.com>
* safe_memory.h: Include <new> rather than <new.h> for gcc 3.
2002-07-11 Conrad Scott <conrad.scott@dsl.pipex.com>
* safe_memory.h: New file extracted from "woutsup.h".
* woutsup.h: Move the "safe" new/delete macros into the new
"safe_memory.h" header file and include that here.
* cygserver_client.cc: Explicitly include "safe_memory.h" for
client-side code.
(client_request::make_request): Use the "safe" new/delete macros
unconditionally, i.e. use them on the client side as well as on
the server side.
* cygserver_transport.cc: Explicitly include "safe_memory.h" for
client-side code.
(create_server_transport): Use the "safe" new/delete macros
unconditionally, i.e. use them on the client side as well as on
the server side.
* shm.cc: Include "safe_memory.h".
(client_shmmgr::instance): Use the "safe" new/delete macros.
(client_shmmgr::shmdt): Ditto.
(client_shmmgr::new_segment): Ditto.
2002-07-11 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_process (process::process): Add the client's cygpid
and winpid to all tracing statements as appropriate.
(process::exit_code): Ditto.
(process_cache::check_and_remove_process): Ditto.
* cygserver_shm.cc (server_shmmgr::shmat): Ditto.
(server_shmmgr::shmdt): Ditto.
(server_shmmgr::shmctl): Add a process object argument and remove
the explicit cygpid argument. Add the client's cygpid and winpid
to all tracing statements as appropriate.
(server_shmmgr::shmget): Ditto.
(client_request_shm::serve): Update for the new signature of the
shmctl and shmget methods.
2002-07-11 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver.cc (client_request_shutdown::serve): Don't set the
shutdown flag directly, but send a SIGINT, as the signal handler
sets the flag and the signal breaks the pause(2) in the main loop.
(print_usage): Add new options.
(main): Add new --cleanup-threads and --request-threads options to
set the number of threads used by the daemon. Use pause(2) rather
the win32 Sleep in the main loop.
* shm.cc (shmat): Add sigframe.
(shmctl): Ditto.
(shmdt): Ditto.
(shmget): Ditto.
2002-07-11 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc: Automatically detach processes from any
segments they are attached to at exit.
(class server_shmmgr::attach_t): New class.
(server_shmmgr::segment_t::IS_DELETED): Rename and make private.
(server_shmmgr::segment_t::_sequence): Make private.
(server_shmmgr::segment_t::_flg): Ditto.
(server_shmmgr::segment_t::_hFileMap): Ditto.
(server_shmmgr::segment_t::_attach_head): New private field.
(server_shmmgr::segment_t::segment_t): Initialise new fields.
Make non-inline.
(server_shmmgr::segment_t::~segment_t): New method.
(server_shmmgr::segment_t::is_deleted): Ditto.
(server_shmmgr::segment_t::is_pending_delete): Ditto.
(server_shmmgr::segment_t::mark_deleted): Ditto.
(server_shmmgr::segment_t::attach): Ditto.
(server_shmmgr::segment_t::detach): Ditto.
(server_shmmgr::segment_t::find): Ditto.
(class server_shmmgr::cleanup_t): New class.
(server_shmmgr::_shm_atts): New private field.
(server_shmmgr::shmat): Add a process object argument to replace
the removed process_cache, cygpid and winpid arguments. Remove
the process_cache manipulations. Move body of code to the
segment_t::attach method. Increment _shm_atts when required.
Update tracing statements.
(server_shmmgr::shmdt): Add a process object argument to replace
the removed cygpid argument. Move body of code to the
segment_t::detach method. Decrement _shm_atts when required.
Update tracing statements.
(server_shmmgr::shmget): Use the new segment_t::is_deleted method.
(server_shmmgr::server_shmmgr): Initialise the new _shm_atts
field.
(server_shmmgr::delete_segment): Remove the CloseHandle code, as
this is now done in the segment_t destructor.
(client_request_shm::serve): Look up the client's process object
and pass to the server_shmmgr::shmat and server_shmmgr::shmdt
methods rather than passing the cache, winpid and cygpid.
* cygserver_process.h: Add a cygpid to the process object to make
it more useful and then pass process objects rather than winpids
where possible.
(cleanup_routine::cleanup): Change argument to be a pointer to a
process object.
(class process): Re-order fields for no discernible reason.
(process::_cygpid): New field.
(process::process): Add a cygpid argument.
(process::winpid): New method.
(process::cygpid): Ditto.
(process::add): Make public, as it always should have been.
(process_cache::process): Add a cygpid argument.
* cygserver_process.cc (process::process): Add a cygpid argument
and use it to initialise the `_cygpid' field. Re-order
initialisers to match new field order.
(process::cleanup): Pass `this' rather than just the winpid to
cleanup_routine::cleanup.
(process_cache::process): Add a cygpid argument and pass it to the
process object constructor.
* include/sys/shm.h (shmatt_t): Make unsigned as per SUSv3.
(shm_info::shm_atts): New field.
2002-07-11 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc (class server_shmmgr::segment_t): Add `_'
prefix to the names of all fields.
2002-07-10 Conrad Scott <conrad.scott@dsl.pipex.com>
* msg.cc: New file of stub functions, no functionality.
* sem.cc: Ditto.
* shm.cc (client_shmmgr::shmctl): Add support for an out shm_info
buffer for the SHM_INFO command.
(client_shmmgr::shmget): Use %X to print keys.
* include/sys/ipc.h: Comment all fields and values.
(IPC_PRIVATE): Change to be non-negative.
* include/sys/msg.h: New file with SUSv3 and ipcs(8) interfaces.
* include/sys/sem.h: Ditto.
* include/sys/shm.h: Comment all fields and values.
(struct shm_info): New struct.
* cygserver_shm.h (client_request_shm::shminfo): Rename.
(client_request_shm::shm_info): New method.
(client_request_shm::_parameters.out.hFileMap): Move into union.
(client_request_shm::_parameters.out.shminfo): Rename.
(client_request_shm::_parameters.out.shm_info): New field.
* cygserver_shm.cc (server_shmmgr::_shm_ids): Rename.
(server_shmmgr::_shm_tot): New field.
(server_shmmgr::shmctl): Rename `out_shminfo' argument. Add
`out_shm_info' argument. Fill in the `out_shm_info' argument in
the SHM_INFO command.
(server_shmmgr::shmget): Check `shmflg' against the mode of
existing segments as per Stevens 1990, p. 123.
(server_shmmgr::server_shmmgr): Initialise the new `_shm_tot'
field.
(server_shmmgr::new_segment): Set ENOMEM if CreateFileMapping
fails. Pass `size' to new_segment.
(server_shmmgr::new_segment): Add size argument and use it to
check against and update the new `_shm_tot' field.
(server_shmmgr::delete_segment): Update the new `_shm_tot' field.
* Makefile.in (DLL_OFILES): Add new DLL object files.
2002-07-09 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_transport_pipes.cc: The main change is to make the
client try harder to connect to the server if it's previously
connected, and so has good grounds for believing that the server
is running.
(MAX_WAIT_NAMED_PIPE_RETRY): Change to be an enumerator.
(WAIT_NAMED_PIPE_TIMEOUT): Ditto.
(transport_layer_pipes::accept): Use interlocked operators on
`pipe_instance'.
(transport_layer_pipes::close): Rearrange so that FlushFileBuffers
and DisconnectNamedPipe are only called for accepted endpoints.
Use interlocked operators on `pipe_instance'.
(transport_layer_pipes::read): Use set_errno where required.
(transport_layer_pipes::write): Ditto.
(transport_layer_pipes::connect): Add local static variable
`assume_cygserver'. Set it if a connection is made to cygserver,
clear it if a connection is not made even after retrying. If set,
ignore all errors from CreateFile and retry the connection. Catch
the situation where WaitNamedPipe fails to wait [sic] and add a
`Sleep (0)' so that the server gets a chance to run.
2002-07-03 Conrad Scott <conrad.scott@dsl.pipex.com>
* dcrt0.cc: Only check for cygserver if and when required.
(dll_crt0_1): Remove call to `cygserver_init ()'.
* fhandler_tty.cc (fhandler_tty_slave::open): Change the cygserver
logic to allow for the fact that `cygserver_init ()' may not yet
have been called.
(fhandler_tty_slave::cygserver_attach_tty): Tweak the cygserver
request logic to conform to the practice elsewhere in the code.
* tty.cc (tty::common_init): Add an explicit call to
`cygserver_init ()' if it hasn't already been called.
* include/cygwin/cygserver.h (CYGSERVER_UNAVAIL): Rename from
`CYGSERVER_DEAD'.
(client_request_get_version::check_version): Make available in
cygserver as well the DLL.
(check_cygserver_available): Ditto. Remove `check_version_too'
argument.
(cygserver_init): Ditto. And likewise.
* cygserver_client.cc (client_request_get_version::check_version):
Make available in cygserver as well the DLL.
(client_request::make_request): This may now be called without
`cygserver_init ()' having been called first. Detect this and
call it as required. Add tracing.
(check_cygserver_available): Make available in cygserver as well
the DLL. Remove `check_version_too' argument and always check the
version information. And since this is called from within
`cygserver_init ()', force `cygserver_running' before calling
`client_request::make_request ()'.
(cygserver_init): Make available in cygserver as well the DLL.
Remove `check_version_too' argument.
2002-07-03 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc: Implement the ipcs(8) interfaces, IPC_INFO,
SHM_STAT and SHM_INFO.
(server_shmmgr::segment_t::sequence): New static field.
(server_shmmgr::segment_t::key): Remove field, use the new
ds.shm_perm.key field instead.
(server_shmmgr::segment_t::shmid): Remove field.
(server_shmmgr::segment_t::intid): New field.
(server_shmmgr::segment_t::segment_t): Use the `key' argument to
initialise `ds.shm_perm.key'. Change from using `shmid' to
`intid'.
(server_shmmgr::_shmseg_cnt): Renamed from `_shmid_cnt'.
(server_shmmgr::_intid_max): Renamed from `_shmid_max.
(server_shmmgr::shmat): Move the out arguments to the start of the
argument list. Rename the `pid' argument as `cygpid'. Add
tracing. Pass an intid to `find ()', not a shmid.
(server_shmmgr::shmctl): Add separate out arguments. Rename the
`pid' argument as `cygpid'. Add support for the ipcs(8)
interfaces. Add tracing. Pass an intid to `find ()', not a
shmid.
(server_shmmgr::shmdt): Rename the `pid' argument as `cygpid'.
Add tracing. Pass an intid to `find ()', not a shmid.
(server_shmmgr::shmget): Add a separate out arguments. Rename the
`pid' argument as `cygpid'. Add tracing.
(server_shmmgr::server_shmmgr): Update for new field names.
(server_shmmgr::find_by_key): Update for the new `ds.shm_perm.key'
field.
(server_shmmgr::find): Update to use the new `segment_t::intid'
field.
(server_shmmgr::new_segment): Rename the `pid' argument as
`cygpid'. Check that the requested size is within bounds. Handle
new error result from `new_segment (key, HANDLE)'.
(server_shmmgr::new_segment): Work with intids, not shmids. Check
that the new intid is within bounds. Update for new field names.
(server_shmmgr::delete_segment): Pass an intid to `find ()', not a
shmid. Update for new field names.
(client_request_shm::serve): Check that the incoming message
length is the size of the `_parameters.in' struct, not of the
whole in/out parameter union. Likewise, set the outgoing message
length to the size of the `_parameters.out' struct. Update for
the new server_shmmgr interfaces.
* include/sys/ipc.h (ipc_perm::key): New field.
* include/sys/shm.h (SHM_INFO): New constant.
* cygserver_ipc.h (IPCMNI): New constant.
(ipc_int2ext): Add `sequence' argument and munge this into the
external ipc id.
(ipc_ext2int_subsys): Unmunge the sequence number from the
external ipc id.
(ipc_ext2int): Ditto.
(ipc_inc_id): Remove.
(ipc_dec_id): Remove.
* cygserver_shm.h (SHMMAX): New constant.
(SHMMIN): Ditto.
(SHMMNI): Ditto.
(SHMSEG): Ditto.
(SHMALL): Ditto.
(client_request_shm::_parameters): Re-arrange as a union of two
separate structs, one for in arguments, the other for out.
(client_request_shm::shmid): Update for the new parameter layout.
(client_request_shm::ds): Ditto.
(client_request_shm::info): New method.
* shm.cc (client_shmmgr::_shmat_cnt): New static field.
(client_shmmgr::shmat): Add locking. Add tracing.
(client_shmmgr::shmctl): Update for ipcs(8) commands. Add
tracing. Add more argument checking.
(client_shmmgr::shmdt): Add locking. Add tracing. Update the new
`_shmat_cnt' field.
(client_shmmgr::shmget): Add tracing.
(client_shmmgr::fixup_shms_after_fork): Add tracing. Add
consistency checking.
(client_shmmgr::attach): Add more tracing.
(client_shmmgr::new_segment): Update the new `_shmat_cnt' field.
(client_request_shm::client_request_shm): Update for the new
parameter layout. Set the outgoing message length to the size of
the `_parameters.in' struct, not of the whole in/out parameter
union.
2002-07-02 Conrad Scott <conrad.scott@dsl.pipex.com>
* shm.cc: Remove the use of a static client_shmmgr object.
(client_shmmgr::_instance): New static variable.
(client_shmmgr::instance): Allocate a new shmmgr on the heap,
rather than using a local static object.
2002-07-01 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_transport.cc (create_server_transport): Fix
cut-and-paste error.
2002-06-30 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_client.cc (client_request::handle_request): Don't
bother with the client request activity marker when compiled with
debugging output.
2002-06-30 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_transport_pipes.cc
(MAX_WAIT_NAMED_PIPE_RETRY): New constant.
(WAIT_NAMED_PIPE_TIMEOUT): Ditto.
(transport_layer_pipes::close): The `pipe' field is now either
NULL or a valid handle, and it should never have the value
`INVALID_HANDLE_VALUE'.
(transport_layer_pipes::read): Ditto.
(transport_layer_pipes::write): Ditto.
(transport_layer_pipes::connect): Ditto.
(transport_layer_pipes::impersonate_client): Ditto.
(transport_layer_pipes::connect): Ditto. New, but still bogus,
retry logic.
2002-06-30 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc (server_shmmgr::server_shmmgr): All fields have
to be initialized now that the singleton is no longer static.
2002-06-30 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc (server_shmmgr::_instance): New static field.
(server_shmmgr::_instance_once): Ditto.
(server_shmmgr::initialise_instance): New static method.
(server_shmmgr::instance): Use a pthread_once_t rather than
relying on a local static variable.
2002-06-30 Conrad Scott <conrad.scott@dsl.pipex.com>
* woutsup.h: Remove all uses of the C++ new and delete operators
throughout cygserver until they are fully thread-safe.
(safe_new0): New macro to replace the C++ new operator.
(safe_new): Ditto.
(safe_delete): New macro to replace the C++ delete operator.
* cygserver_client.cc (client_request::handle_request): Replace
all uses of the C++ new and delete operators with the new macros
from "woutsup.h".
(client_request::make_request): Ditto.
* cygserver_process.cc (~process_cleanup): Ditto.
(process::cleanup): Ditto.
(process_cache::process): Ditto.
(process_cache::check_and_remove_process): Ditto.
* cygserver_shm.cc (server_shmmgr::new_segment): Ditto.
(server_shmmgr::delete_segment): Ditto.
* cygserver_transport.cc (create_server_transport): Ditto.
* cygserver_transport_pipes.cc
(transport_layer_pipes::accept): Ditto.
* cygserver_transport_sockets.cc
(transport_layer_sockets::accept): Ditto.
* threaded_queue.cc (~threaded_queue): Ditto.
(threaded_queue::worker_loop): Ditto.
(threaded_queue::stop): Replace sleep(3) with win32 Sleep.
* cygserver.cc (~server_request): Replace all uses of the C++ new
and delete operators with the new macros from "woutsup.h".
(server_submission_loop::request_loop): Ditto.
(main): Ditto. Replace sleep(3) with win32 Sleep. Replace
iostreams with FILEs.
(print_usage): Replace iostreams with FILEs.
(print_version): Ditto.
2002-06-30 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_transport_sockets.cc
(transport_layer_sockets::accept): Rename local variable
`accept_fd' to avoid shadowing the `fd' field.
2002-06-29 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygwin_ipc.h: Moved (back) to "include/sys/ipc.h".
* cygwin_shm.h: Moved (back) to "include/sys/shm.h".
* include/sys/ipc.h: New file.
* include/sys/shm.h: New file.
* cygserver_shm.h: Update for new header file locations.
* ipc.cc: Ditto.
2002-06-28 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_client.cc (client_request::make_request): Comment out
a verbose tracing statement.
* cygserver_process.cc (process_cache::sync_wait_array): Fix
broken assert.
* include/cygwin/cygserver.h (class client_request): Remove excess
use of `class' qualifier in declarations.
(class client_request_get_version): Ditto.
(class client_request_shutdown): Ditto.
(class client_request_attach_tty): Ditto.
2002-06-28 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_ipc.h: New file.
* cygserver_shm.h: Re-written from scratch.
* cygserver_shm.cc: Ditto.
* shm.cc: Ditto.
2002-06-28 Conrad Scott <conrad.scott@dsl.pipex.com>
* threaded_queue.h (class queue_request): Re-write.
(threaded_queue_thread_function): Remove.
(class queue_process_param): Remove.
(class threaded_queue): Re-write.
(class queue_submission_loop): New version of the old
`queue_process_param' class.
(TInterlockedExchangePointer): New templated function.
(TInterlockedCompareExchangePointer): Ditto.
* threaded_queue.cc (worker_function): Remove.
(class threaded_queue): Re-write.
(class queue_process_param): Remove.
(class queue_submission_loop): New version of the old
`queue_process_param' class.
* include/cygwin/cygserver_process.h (process_cleanup): Re-write.
(class process_process_param): Remove.
(class cleanup_routine): Re-write.
(class process): Re-write.
(class process_cache): Re-write.
* cygserver_process.cc (process_cleanup): Re-write.
(class process_process_param): Remove.
(class cleanup_routine): Re-write.
(class process): Re-write.
(class process_cache): Re-write.
* cygserver.cc (request_count): Remove unused variable.
(class server_request): Move methods inline.
(class server_process_param): Remove.
(class server_request_queue): Remove.
(request_queue): Move into `main ()' and change type to
`threaded_queue'.
(request_loop): Remove.
(class server_submission_loop): New version of the old
`server_process_param' class.
(shutdown_server): New variable.
(client_request_shutdown::serve): Set `shutdown_server' to trigger
shutdown.
(handle_signal): Ditto.
(main): Install signal handler for SIGINT rather than SIGQUIT.
Use new interfaces for the `request_queue' and the `cache'.
Create a `server_submission_loop' and add to the `request_queue'.
Add check for the `shutdown_server' variable to the main loop.
* cygserver_shm.cc (client_request_shm::serve): Release the
process object after use.
2002-06-27 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_client.cc (client_request::handle_request): Correct
tracing statement.
* cygserver_transport_pipes.cc: Remove local definition of
FILE_FLAG_FIRST_PIPE_INSTANCE constant.
* cygwin_ipc.h: Update copyright notice.
* cygwin_shm.h: Ditto.
* woutsup.h: Add definition of _WIN32_WINNT.
2002-06-24 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_client (client_request::make_request): Replace my
inappropriate use of set_errno () with error_code () throughout.
2002-06-24 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver.h: Add forward declarations of class
transport_layer_base and class process_cache to reduce
dependencies between header files.
* include/cygwin/cygserver_process.h: Add include of
"threaded_queue.h".
* cygserver.cc: Remove unnecessary cygserver header files.
* cygserver_client.cc: Ditto.
* cygserver_process.cc: Ditto.
* cygserver_shm.cc: Ditto.
* cygserver_shm.h: Ditto.
* cygserver_transport_pipes.cc: Ditto.
* dcrt0.cc: Ditto.
* fhandler_tty.cc: Ditto.
* tty.cc: Ditto.
2002-06-24 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.h: Replace <sys/shm.h> with "cygwin_shm.h" after
merge from HEAD.
* cygwin_ipc.h: Update with changes to include/sys/ipc.h lost in
merge from HEAD.
* cygwin_shm.h: Ditto.
2002-06-21 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver.cc: The tests for a duplicate server instance are now
the responsibility of the transport layer.
(request_loop): Use new `recoverable' flag in call to
`cygserver_transport::accept ()' and shutdown on an unrecoverable
error.
(main): Never call `cygserver_init ()'. Fake `cygserver_running'
just for sending a shutdown request.
* cygserver_client.cc (client_request::send): Comment out
message-size tracing statements as verbose.
(client_request::handle): Ditto.
(client_request_get_version::check_version): #ifdef as DLL-only.
(check_cygserver_available): Ditto.
(cygserver_init): Ditto.
* include/cygwin/cygserver.h
(client_request_get_version::check_version): #ifdef as DLL-only.
(check_cygserver_available): Ditto.
(cygserver_init): Ditto.
* include/cygwin/cygserver_transport.h
(transport_layer_base::impersonate_client): #ifdef as
cygserver-only.
(transport_layer_base::revert_to_self): Ditto.
(transport_layer_base::listen): Ditto.
(transport_layer_base::accept): Ditto. Add a `recoverable' out
flag for error handling.
* include/cygwin/cygserver_transport_sockets.h: Ditto.
* include/cygwin/cygserver_transport_pipes.h: Ditto.
(transport_layer_pipes): Change type of the `pipe_name' field.
Remove the `inited' field, as unnecessary. Add new
`is_accepted_endpoint' field.
* include/cygwin/cygserver_transport.cc
(transport_layer_base::impersonate_client): #ifdef as
cygserver-only.
(transport_layer_base::revert_to_self): Ditto.
* include/cygwin/cygserver_transport_sockets.cc
(transport_layer_sockets::listen): #ifdef as cygserver-only.
(transport_layer_sockets::accept): #ifdef as cygserver-only.
Analyse any errno from `accept ()' and set `recoverable' as
appropriate.
* cygserver_transport_pipes.cc: Add local #define of
`FILE_FLAG_FIRST_PIPE_INSTANCE'.
(pipe_instance_lock_once): New variable.
(pipe_instance_lock): Ditto.
(pipe_instance): Ditto.
(initialise_pipe_instance_lock): New function.
(transport_layer_pipes::transport_layer_pipes): Change
initialization of `pipe_name'. Initialize `is_accepted_endpoint'
as appropriate. Remove use of `inited'.
(transport_layer_pipes::impersonate_client): #ifdef as
cygserver-only.
(transport_layer_pipes::revert_to_self): Ditto.
(transport_layer_pipes::listen): Ditto.
(transport_layer_pipes::accept): Ditto. Keep track of how often
many named pipes have been created, in the `pipe_instance'
variable, and pass the `FILE_FLAG_FIRST_PIPE_INSTANCE' flag on the
open of the first instance. Analyse the error code from
`CreateNamedPipe ()' and set the `recoverable' flag as
appropriate.
(transport_layer_pipes::close): Update the `pipe_instance' count.
2002-06-18 Conrad Scott <conrad.scott@dsl.pipex.com>
* woutsup.h (cygserver_running): Add declaration.
(api_fatal): Eliminate.
* include/cygwin/cygserver.h
(client_request_get_version::check_version): Change return type to
bool.
(check_cygserver_available): New function.
(cygserver_init): Add check_version_too argument.
* cygserver_client.cc (allow_daemon): Make a bool.
(client_request_get_version::make_request): See errno on error.
Remove special case for CYGSERVER_REQUEST_GET_VERSION; this is now
handled in cygserver_init().
(client_request_get_version::check_version): Use syscall_printf()
instead of api_fatal(). Return true if cygserver version is
compatible.
(check_cygserver_available): New function; code moved here from
cygserver_init().
(cygserver_init): Move some code into check_cygserver_available().
* cygserver.cc (__set_errno): Copy from debug.cc so that
set_errno() can be used when __OUTSIDE_CYGWIN__.
(main): Call cygserver_init() to set up cygserver_running and add
checks against this to (try and) prevent multiple copies of
cygserver running simultaneously. Remember to delete all
transport connections so that (one day) the transport classes can
tidy up on cygserver shutdown.
2002-06-17 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver.cc (main): Adjust tracing output for a cleaner display
when compiled without --enable-debugging.
* threaded_queue.cc (threaded_queue::cleanup): Ditto.
(queue_process_param::stop): Ditto.
* include/cygwin/cygserver.h
(client_request::make_request): Make non-virtual.
(client_request::send): Make virtual and protected, not private.
(client_request_attach_tty::send): New virtual method.
* cygserver_client.cc: Use the `msglen()' accessor rather than
`_header.msglen' throughout.
(client_request_attach_tty::send): New method.
(client_request::make_request): Remove the explicit close of
`transport' as it is closed on deletion.
2002-06-17 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver.h: Change the client_request classes to
give greater encapsulation and to allow variable length requests
and replies.
(enum cygserver_request_code): Now client_request::request_code_t.
(class request_header): Now client_request::header_t. Make a
union of the request_code and the error_code. The `cb' field,
which was the buffer length, is now the `size_t msglen' field.
(struct request_get_version): Now
client_request_get_version::request_get_version.
(struct request_shutdown): Remove unused type.
(struct request_attach_tty): Now
client_request_attach_tty::request_attach_tty.
(client_request::_buf): Make field const.
(client_request::_buflen): New const private field.
(client_request::request_code): New accessor.
(client_request::error_code): Ditto.
(client_request::msglen): Ditto.
(client_request::handle_request): New static method.
(client_request::make_request): New virtual method.
(client_request::handle): New method.
(client_request::send): Make private.
(client_request_get_version::check_version): New method.
(client_request_get_version::serve): Make private.
(client_request_get_version::version): Ditto.
(client_request_shutdown::serve): Ditto.
(client_request_attach_tty::req): Ditto.
(client_request_attach_tty::serve): Ditto.
(client_request_attach_tty::from_master): Make method const.
(client_request_attach_tty::from_master): Ditto.
* cygserver_client.cc
(client_request_get_version::client_request_get_version): Track
changes to the client_request classes.
(client_request_attach_tty::client_request_attach_tty): Ditto.
(client_request_get_version::check_version): New method to
encapsulate code from cygserver_init().
(client_request_shutdown::client_request_shutdown): Move into
"cygserver.cc".
(client_request::send): Track changes to the client_request
classes. Add more error checking.
(client_request::handle_request): New static method containing the
first half of the old server_request::process() code.
(client_request::make_request): New method to replace the old
cygserver_request() function.
(client_request::handle): New method containing the second half of
the old server_request::process() code.
(cygserver_init): Track changes to the client_request classes. In
particular, some code moved into the
client_request_get_version::check_version() method.
* cygserver.cc (client_request_attach_tty::serve): Track changes
to the client_request classes. In particular, only return a reply
body if some handles are successfully duplicated for the client.
And remove goto's.
(client_request_get_version::serve): Track changes to the
client_request classes.
(client_request_shutdown::serve): Ditto.
(class client_request_invalid): Dead, and so young too.
(server_request::request_buffer): Remove unnecessary field.
(client_request_shutdown::client_request_shutdown): Moved here
from "cygserver_client.cc".
(server_request::process): Implementation moved into the new
client_request::handle_request() and client_request::handle()
methods.
* cygserver_shm.h (class client_request_shm): Put client- and
server-specific interfaces inside #ifdef/#ifndef __INSIDE_CYGWIN__
guards.
(client_request_shm::serve): Make private.
* cygserver_shm.cc
(client_request_shm::client_request_shm): Track changes to the
client_request classes.
(client_request_shm::serve): Ditto
* shm.cc (client_request_shm::client_request_shm): Ditto. Use
alloc_sd() rather than set_security_attribute() to get access to
the SECURITY_DESCRIPTOR length, so that we can use it to set the
request body length.
(shmat): Track changes to the client_request classes. In
particular, allocate client_request objects on the stack rather
than on the heap, and use the client_request::make_request()
method rather than the old cygserver_request() function.
(shmdt): Ditto.
(shmctl): Ditto.
(shmget): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::cygserver_attach_tty): Ditto.
2002-06-17 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver_transport.h
(cygserver_transport::read): Change buffer type to void *.
(cygserver_transport::write): Ditto.
* include/cygwin/cygserver_transport_sockets.h
(cygserver_transport_sockets::read): Ditto.
(cygserver_transport_sockets::write): Ditto.
* include/cygwin/cygserver_transport_pipes.h
(cygserver_transport_pipes::read): Ditto.
(cygserver_transport_pipes::write): Ditto.
* cygserver_transport_sockets.cc
(cygserver_transport_sockets::read): Ditto.
(cygserver_transport_sockets::write): Ditto.
* cygserver_transport_pipes.cc
(cygserver_transport_pipes::read): Ditto. Set errno on error, to
match behaviour of cygserver_transport_sockets class.
(cygserver_transport_pipes::write): Ditto.
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver.cc (version): New static variable.
(server_request_queue::add_connection): Remove my gratuitous use
of studly caps.
(setup_privileges): Declare static.
(handle_signal): Ditto.
(longopts): Make a local variable of main().
(opts): Ditto.
(print_usage): New function.
(print_version): Ditto (tip of the hat to Joshua Daniel Franklin
for inspiration here).
(main): More argument checking. Add --help and --version options.
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver.h (client_request::serve): Make pure
virtual.
* cygserver.cc (client_request::serve): Remove definition of pure
virtual method.
(class client_request_invalid): New class.
(server_request::process): Use new client_request_invalid
class. And remove goto's.
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver.cc (class server_request): Add virtual destructor.
(server_request_queue::addConnection): New method to replace bad
virtual add() method.
(request_loop): Replace call to queue->add() with call to
queue->addConnection().
(server_request::server_request): Use field initialization.
(server_request::~server_request): New virtual destructor.
(server_request::process): Remove close and delete of
transport_layer_base object. It is deleted by the server_request's
own destructor and closed by its own destructor.
* include/cygwin/cygserver.h
(client_request::operator request_header): Remove unused method.
* cygserver_client.cc: Ditto.
* include/cygwin/cygserver_process.h
(class cleanup_routine): Add virtual destructor.
(cleanup_routine::cleanup): Make pure virtual.
(class process_cache): Make destructor non-virtual.
(process_cache::add): Ditto.
* cygserver_process.cc
(cleanup_routine::~cleanup_routine): New virtual destructor.
* include/cygwin/cygserver_transport.h
(class transport_layer_base): Add virtual destructor.
* cygserver_transport.cc
(transport_layer_base::~transport_layer_base): New virtual
destructor.
* include/cygwin/cygserver_transport_pipes.h
(class transport_layer_pipes): Add virtual destructor.
* cygserver_transport_pipes.cc
(transport_layer_pipes::~transport_layer_pipes): New virtual
destructor.
(transport_layer_pipes::close): Null out handle after closing.
* include/cygwin/cygserver_transport_sockets.h
(class transport_layer_sockets): Add virtual destructor.
* cygserver_transport_sockets.cc
(transport_layer_sockets::~transport_layer_sockets): New virtual
destructor.
(transport_layer_sockets::close): Null out fd after closing.
* threaded_queue.h (class queue_request): Add virtual destructor.
(queue_request::process): Make pure virtual.
* threaded_queue.cc (~queue_request): New virtual destructor.
(queue_request::process): Remove definition of pure virtual
method.
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver.h (client_request::send): Make
non-virtual.
(class client_request_attach_tty): Put client- and server-specific
interfaces inside #ifdef/#ifndef __INSIDE_CYGWIN__ guards.
* cygserver_client.cc: Ditto.
(cygserver_init): Fix error handling.
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver.cc: Throughout the code, check and correct level of
the XXX_printf() functions used. Comment out several of the
debug_printf() calls with "// verbose:". Reformat and correct
typos of some of the XXX_printf() formats.
* cygserver_process.cc: Ditto.
* cygserver_shm.cc: Ditto.
* cygserver_transport_pipes.cc: Ditto.
* cygserver_transport_sockets.cc: Ditto.
* shm.cc (hi_ulong): New function to allow printing of a 64-bit
key with current small_printf implementation.
(lo_ulong): Ditto.
(client_request_shm::client_request_shm): Use hi_ulong() and
lo_ulong() in call to debug_printf().
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver_shm.cc: Remove #define __INSIDE_CYGWIN__ from around
<sys/shm.h> as it no longer contains any internal code.
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/sys/ipc.h (IPC_PRIVATE): Add cast to key_t.
(IPC_INFO): New flag for ipcs(8).
(IPC_RMID IPC_SET IPC_STAT): Renumber.
* include/sys/shm.h (SHM_RDONLY SHM_RND): Renumber with distinct
values [sic].
(class _shmattach): Internal type moved to "cygserver_shm.h".
(class shmnode): Ditto.
(class shmid_ds): Ditto.
(struct shmid_ds): Add spare fields.
(struct shminfo): New type for IPC_INFO interface.
* cygserver_shm.h: Remove obsolete #if 0 ... #endif block.
(class shm_cleanup): Remove unused class.
(struct _shmattach): Internal type moved from <sys/shm.h>.
(struct shmnode): Ditto.
(struct int_shmid_ds): Ditto. Renamed to avoid name clash with
public interface struct shmid_ds. Use the shmid_bs structure as a
field.
* cygserver_shm.cc: Remove obsolete #if 0 ... #endif block.
(client_request_shm::serve): Update for redefinition of
int_shmid_ds structure.
* shm.cc (build_inprocess_shmds): Ditto.
(fixup_shms_after_fork): Ditto.
(shmctl): Ditto.
(shmget): Ditto. Remove obsolete #if 0 ... #endif code.
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* include/cygwin/cygserver_transport.h
(transport_layer_base::transport_layer_base): Remove since it is
now redundant.
(transport_layer_base::listen): Make a pure virtual method.
(transport_layer_base::accept): Ditto.
(transport_layer_base::close): Ditto.
(transport_layer_base::read): Ditto.
(transport_layer_base::write): Ditto.
(transport_layer_base::connect): Ditto.
* cygserver_transport.cc
(transport_layer_base::transport_layer_base): Remove since it is
now redundant.
(transport_layer_base::listen): Remove since it is now a pure
virtual method.
(transport_layer_base::accept): Ditto.
(transport_layer_base::close): Ditto.
(transport_layer_base::read): Ditto.
(transport_layer_base::write): Ditto.
(transport_layer_base::connect): Ditto.
2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygserver.cc (check_and_dup_handle): Only use security code if
running on NT, i.e. if wincap.has_security().
(client_request_attach_tty::serve): Add check for has_security().
* cygserver_process.cc (process_cache::process): Use DWORD winpid
throughout to avoid win32 vs. cygwin pid confusion.
(process::process): Ditto.
* cygserver_shm.cc (client_request_shm::serve): Only use security
code if running on NT, i.e. if wincap.has_security().
* cygserver_shm.h (client_request_shm::parameters.in): Replace the
ambiguous pid field with cygpid and winpid fields.
(client_request_shm::client_request_shm): Reduce to only two
client-side constructors: one for SHM_CREATE, another for all the
other requests.
* shm.cc (client_request_shm::client_request_shm):
Ditto. Initialize cygpid and winpid fields here. On NT initialize
sd_buf here using set_security_attribute() to make use of the euid
and egid.
(shmat): Use new client_request_shm constructor.
(shmdt): Ditto.
(shmctl): Ditto.
(shmget): Ditto. Remove security code, now performed in the
relevant client_request_shm constructor.
* include/cygwin/cygserver_process.h: (class cleanup_routine):
Change winpid type to DWORD.
(class process): Ditto.
2002-06-15 Conrad Scott <conrad.scott@dsl.pipex.com>
* woutsup.h: New file.
* cygserver.cc: Use "woutsup.h" and new XXX_printf macros.
(getfunc): New function, copied verbatim from "strace.cc".
(__cygserver__printf): New function.
* cygserver_client.cc: Use "woutsup.h" and new XXX_printf macros.
* cygserver_process.cc: Ditto.
* cygserver_shm.cc: Ditto.
* cygserver_transport.cc: Ditto.
* cygserver_transport_pipes.cc: Ditto.
* cygserver_transport_sockets.cc: Ditto.
* threaded_queue.cc: Ditto.
* shm.cc: Remove trailing \n from XXX_printf format strings.
* Makefile.in: Remove special __OUTSIDE_CYGWIN__ case for
cygserver_shm.cc.
* cygthread.h (cygthread::exit_thread): Declare new method.
* fhandler.h (fhandler_tty_master::hThread): Delete.
(fhandler_tty_master::output_thread): Define.
* fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Adjust
constructor.
(fhandler_tty_master::init): Use cygthread rather than handle.
(process_output): Use cygthread method to exit.
(fhandler_tty_master::fixup_after_fork): Set output_thread to NULL after fork.
(fhandler_tty_master::fixup_after_exec): Set output_thread to NULL after
spawn/exec.
* tty.cc (tty_list::terminate): Detach from output_thread using cygthread
method.
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.