tty_min, mtinfo and fs_info thoroughout.
* fhandler.h: Redefine all set_close_on_exec methods to take a bool
argument.
(enum conn_state): Rename from connect_state.
(class fhandler_base): Rename some status flags to align with
accessor method names. Drop encoded flag entirely. Unify status
accessor methods. Const'ify all read accessor methods.
(class fhandler_socket): Ditto.
(class fhandler_dev_raw): Ditto.
* fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat()
instead of evaluating FATness of file system here.
(fhandler_disk_file::opendir): Drop call to set_encoded().
(fhandler_disk_file::readdir): Use pc.isencoded() directly.
* mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods.
* path.cc (fsinfo_cnt): Add.
(fs_info::update): Accomodate class changes. Evaluate file system
name specific flags right here. Add thread safety for reading and
writing global fsinfo array.
* path.h (enum path_types): Drop values for flags kept in fs already.
(struct fs_info): Move status informatin into private struct type
status_flags. Add accessor methods. Remove path and file system
name string arrays in favor of status bits.
(class path_conv): Use new fs_info status information where
appropriate.
(path_conf::fs_has_ea): Rename from fs_fast_ea.
(path_conf::fs_has_acls): New method.
(path_conf::root_dir): Remove.
(path_conf::volname): Remove.
* syscalls (statfs): Evaluate root dir locally.
* tty.h (class tty_min): Unify status accessor methods. Const'ify
all read accessor methods.
TIOCSWINSZ. It is not an error for ioctl_request_event to be missing.
* sigproc.cc (pending_signals::save): New function.
(pending_signals::restore): Ditto.
(sig_clear): Save/restore current queue pointer.
(wait_sig): Delete signals marked as such.
* sigproc.h (__SIGDELETE): New enum.
* cygwin.din: Make clock SIGFE. Add clock_gettime, sigwaitinfo, timer_create,
timer_delete, timer_settime.
* include/cygwin/version.h: Reflect above additions.
* fork.cc (fork_child): Call fixup_timers_after_fork.
* signal.cc (sigwait): Remove unused variable.
* timer.cc: New file.
(clock_gettime): Define new function.
(timer_tracker): Define new struct used by timer functions.
(timer_tracker::timer_tracker): New function.
(to_us): New function.
(timer_thread): New function.
(timer_tracker::settime): New function.
(timer_create): New function.
(timer_settime): New function.
(timer_delete): New function.
(fixup_timers_after_fork): New function.
* cygthread.cc: Bump thread count.
* signal.cc (sigwaitinfo): Define new function.
(sigwait): Redefine based on sigwaitinfo.
* include/cygwin/signal.h (sigwaitinfo): Declare.
(sigwait): Ditto.
* dtable.cc (dtable::vfork_parent_restore): Avoid double close of ctty when
ctty == ctty_on_hold.
* cygtls.h (_threadinfo::threadkill): New element.
(_threadinfo::set_threadkill): Declare new function.
(_threadinfo::reset_threadkill): Declare new function.
* dcrt0.cc (dcrt0_1): Call here so that it will be possible to attach to
running process with #(*& Windows Me/9x.
(initial_env): Try to initialize strace if uninitialized.
* gendef: Don't zero signal if threadkill is set since that will happen in the
called function.
* signal.cc (sigwait): Ensure cleanup in error conditions.
* sigproc.cc (sig_send): Clear packet mask storage.
(wait_subproc): Fill in child exit code in siginfo_t structure.
* thread.cc (pthread_kill): Set threadkill flag.
* tlsoffsets.h: Regenerate. Throughout, use siginfo_t to fill out all signal
information for "kernel" signals.
* cygtls.h (_threadinfo::set_siginfo): Declare new function.
* cygtls.cc (_threadinfo::set_siginfo): Define new function.
* dcrt0.cc (do_exit): Accommodate siginfo_t considerations.
* exceptions.cc (handle_exceptions): Ditto.
(sig_handle_tty_stop): Ditto.
(ctrl_c_handler): Use killsys() to send signal.
(sigpacket::process): Rename from sig_handle. Use siginfo_t field from
sigpacket for everything.
(tty_min::kill_pgrp): Accommodate siginfo_t considerations.
(fhandler_termios::bg_check): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::ioctl): Use killsys() to send signal.
* signal.cc (kill_worker): Rewrite to use siginfo_t second argument.
(kill_pgrp): Ditto.
(kill0): Define new function pulled from kill().
(kill): Rewrite as frontend to kill0.
(killsys): Define new function.
* sigproc.cc (sigelem): Eliminate.
(sigpacket): Move to sigproc.h. Subsume sigelem.
(pending_signals): Use sigpacket rather than sigelem for everything.
(sig_clear): Ditto.
(wait_sig): Ditto.
(sig_send): Rewrite to use siginfo_t argument.
(sig_send): New function wratpper to sig_send with siginfo_t argument.
(wait_subproc): Accommodate siginfo_t considerations.
* thread.cc (pthread_kill): Ditto.
* sigproc.h (sigpacket): Move here.
(sigpacket::process): Declare "new" function.
(sig_handle): Eliminate declaration.
(sig_send): Declare with new paramaters.
(killsys): Declare new function.
(kill_pgrp): Declare.
* winsup.h: Move some signal-specific stuff to sigproc.h.
* include/cygwin/signal.h: Tweak some siginfo_t stuff.
this change throughout.
* dtable.cc (dtable::add_archetype): Use correct count when iterating through
*active* archetypes.
* dtable.cc (dtable::fixup_after_exec): Close handle if close_on_exec and
archetype exists since archetype currently does not set windows close-on-exec
flag (FIXME).
* fhandler_tty.cc (fhandler_tty_slave::open): Change debugging output slightly.
(fhandler_tty_slave::close): Ditto.
(fhandler_tty_slave::fixup_after_fork): Just report on inherited use counts
since since archetype currently does not set windows close-on-exec flag
(FIXME).
* pinfo.cc (_pinfo::set_ctty): Change debugging output slightly.
* cygheap.cc (cygheap_init): Remove open_fhs accommodation and use count
reporting.
* perthread.h (vfork_save::fhctty): New element.
* perthread.h (vfork_save::open_fhs): New element.
* fork.cc (vfork): Muck around with ctty and open_fhs stuff, both of which are
now saved in the vfork_save structure.
(report_tty_counts): New macro. Use throughout for reporting tty use counts.
* dtable.cc (dtable::vfork_child_dup): Add debugging output for usecount
increment. Increment open_fhs if appropriate.
(dtable::vfork_parent_restore): "Close" artificially bumped ctty.
(dtable::vfork_child_fixup): Close ctty since it was bumped prior to vfork.
Save open_fhs around close since the closing of these handles has no effect on
the console.
* fhandler_tty.cc (fhandler_tty_slave::open): Reorganize calls to allow for
easier tracking of usecount modification.
(fhandler_tty_slave::open): Ditto.
(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.
environment variable after error_start detected.
* fhandler_tty_slave.cc (fhandler_tty_slave::close): Clarify debug message.
* syscalls.cc (setsid): Don't increment usecount here, since it will be
automatically decremented on close.
(dtable::release): Move archetype deletion here.
(dtable::vfork_child_dup): Increment ctty usecount to catch later
close_all_files case in parent/child.
(dtable::vfork_child_fixup): Avoid using cygheap->foo where this should really
be using local references. Call close on archetyped handles since the handles
haven't had the noninherit flag set.
* fhandler_tty.cc (fhandler_tty_slave::close): Remove archetype deletion code.
Add defensive error message when DEBUGGING.
(fhandler_tty_common::set_close_on_exec): Use more robust method for checking
whether to set handles into noninherit if there is an archetype associated with
the fhandler.
(init_cheap::ctty): Change to pointer.
* dtable.h (dtable::find_archetype): Declare new function.
(dtable::add_archetype): Declare new function.
(dtable::delete_archetype): Declare new function.
(dtable::narchetypes): Declare.
(dtable::farchetypes): Declare.
(dtable::initial_archetype_size): Declare.
(dtable::dtable): Initialize new fields.
(dtable::initial_archetype_size): Declare.
* dtable.cc (dtable::find_archetype): Define new function.
(dtable::add_archetype): Define new function.
(dtable::delete_archetype): Define new function.
(dtable::initial_archetype_size): Define.
* fhandler.h (fhandler_base::archetype): Declare.
(fhandler_base::usecount): Declare.
* fhandler.cc (fhandler_base::fhandler_base): Initialize new fields.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Pass NULL to third
argument of set_ctty.
* fhandler_tty.cc (fhandler_tty_slave::open): Accommodate new archetype method
to create only one instance of a tty.
(fhandler_tty_slave::close): Don't close handles unless archetype usecount is
zero. When that happens, close archetype too.
(fhandler_tty_slave::dup): Just copy archetype. Set use count appropriately.
Set ctty, if appropriate.
(fhandler_tty_common::dup): Remove slave considerations.
(fhandler_tty_common::set_close_on_exec): Remove cygheap->ctty considerations.
* pinfo.cc (_pinfo::set_ctty): Accommodate new archetype methods.
* pinfo.h (_pinfo::set_ctty): Make third argument explicit.
* syscalls.cc (close_all_files): Decrement controlling tty use count before
closing all handles to allow controlling tty to be closed. Remove previous
controlling tty considerations.
if duping the current ctty.
(fhandler_tty_common::close): Move debugging statement earlier in function.
(fhandler_tty_slave::close): Return success when closing ctty.
* syscalls.cc (close_all_files): Avoid calling fhandler_tty_slave close method
so that open_fhs will not be decremented when closing cygheap ctty.
(setsid): Ditto.
* dcrt0.cc (do_exit): Reorganize to avoid leaving a critical section active
after vfork.
* fhandler.h (fhandler_tty_slave::get_unit): Remove regparm parameter since it
can't work in a virtualized function.
guaranteed to be accurate.
* fhandler_tty.cc (fhandler_tty_slave::open): Increment open_fhs appropriate
when copying ctty.
(fhandler_tty_slave::close): Remove special case handling for exit_state. Use
ctty < 0 check instead.
(fhandler_tty_common::close): Set io_handle to NULL after closing.
* syscalls.cc (close_all_files): Specifically close cygheap->ctty, if
appropriate.
throughout.
* tty.cc (tty::common_init): Remove call to SetKernelObjectSecurity and edit
some comments.
* cygheap.h (init_cygheap::ctty): Add new element.
* devices.in (device::parse): Remove special handling for /dev/tty.
* devices.cc: Regenerate.
* dtable.cc (build_fh_pc): Don't reset /dev/tty device. Let the device opener
do that.
* fhandler_termios.cc (tty_min::set_ctty): Redefine to _pinfo class.
* fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Avoid setting
noninherit flag for ctty.
* tty.h: Move BOOLs to bools.
(tty_min::set_ctty): Redeclare to _pinfo class.
* pinfo.cc (_pinfo::set_ctty): Define new function based on tty_min::set_ctty.
Change first argument from tty number to tty_min class.
* pinfo.h (_pinfo::set_ctty): Declare.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Reflect move of
set_ctty to _pinfo class.
* fhandler_tty.cc (fhandler_tty_slave::open): Treat FH_TTY specially. Use
saved cygheap value if it exists. Otherwise convert to real device and save on
first time open.
(fhandler_tty_common::dup): Potentially set controlling tty if duping a slave
tty.
* syscalls.cc (setsid): Close controlling tty in cygheap.
* tty.cc: Change some BOOLs to bools.
* 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.
* child_info.h: YA update of another magic number.
* gendevices: New file.
* devices.in: New file.
* devices.cc: Regenerate.
* devices.shilka: Remove.
* devices.h: Correctly define device pointers.
(device): Remove now obsolete fields.
(device::native): Renamed from device::fmt.
* dtable.cc (build_fh_dev): Simplify in light of new unit parsing scheme.
(build_fh_pc): Ditto.
* path.cc (win32_device_name): Ditto.
* fhandler.h (fhandler_base::get_native_name): Reflect renaming of fmt to
native.
* fhandler_tty.cc (fhandler_tty_mster::init): Initialize slave device prior to
reporting unit.
CTRL and ALT keys at the time of the last keyboard input event.
(fhandler_console::ioctl): Handle requests to retrieve the keyboard modifiers
via the TIOCLINUX command.
* fhandler_tty.c (fhandler_tty_slave::read): Ditto.
* include/sys/termios.h (TIOCLINUX): New macro definition.
* 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.
* exceptions.cc (early_stuff_init): Delete.
(init_console_handler): New function - top half of early_stuff_init.
(init_global_security): New function - bottom half of early_stuff_init.
(sig_handle): Avoid special hExeced test for SIGINT. Just terminate the
captive process.
(signal_exit): Add debugging output.
* fhandler_tty.cc (fhandler_tty_slave::open): Don't allocate a console if one
already seems to exist. Properly initialize ctrl-c handling if we do allocate
a console.
* winsup.h (early_stuff_init): Delete declaration.
(init_console_handler): New declaration.
(init_global_security): New declaration.
* 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.
is a tty associated with the process. Send SIGHUP on CTRL_LOGOFF_EVENT.
* fhandler_tty.cc (fhandler_tty_slave::open): Adjust console open handle
counter regardless of whether this is a pty or tty.
(fhandler_tty_slave::open): Ditto.
(fhandler_tty_slave::dup): Ditto.
(fhandler_tty_common::set_close_on_exec): Ditto.
(fhandler_tty_master::init_console): Decrement console open handle counter
after init since it will now be handled by all tty open.
* syscalls.cc (setsid): Rework debugging output slightly.
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.
(wincapc:pty_needs_alloc_console): New function.
* wincap.cc: Add pty_needs_alloc_console throughout.
* fhandler_tty.cc (fhandler_tty_slave::open): Open an "invisible" console on
first pty allocation.
(fhandler_tty_slave::dup): Declare new function.
(fhandler_tty_slave::fixup_after_function): Declare new function.
* fhandler_tty.cc (fhandler_tty_slave_open): Only increment
fhandler_console::open_fhs when associated with a pty.
(fhandler_tty_slave::close): Define new function. Decrement
fhandler_console::open_fhs when associated with a pty.
(fhandler_tty_slave::dup): Define new function. Increment
fhandler_console::open_fhs when associated with a pty.
(fhandler_tty_slave::fixup_after_fork): Define new function. Increment
fhandler_console::open_fhs when associated with a pty.
* fhandler_console.cc (fhandler_console::send_winch_maybe): If appropriate,
call tty master function to handle screen size change.
* fhandler_tty.cc (fhandler_tty_master::set_winsize): New function.
(fhandler_tty_master::init): Call set_winsize to set initial screen size.
of console in which tty is operating.
(process_input): Semi-revert previous change. Need to just use current
terminfo settings since this function is running in a thread, blocked when the
terminfo changes.
passed-in termios struct.
* fhandler_console.cc (fhandler_console::read): Prior to loop, make a copy of
current termios for passing to line_edit prior so that all characters are
processed consistently.
* fhandler_tty.cc (fhandler_pty_master::write): Ditto.
(process_input): Make a copy of curent termios prior to read for use in
subsequent line_edit.
* fhandler_termios.cc (fhandler_termios::line_edit): Replace third parameter
with passed-in termios struct and use it throughout rather than the data from
the current fhandler_termios class.
can be < or >.
* fhandler_tty.cc (fhandler_pty_master::write): Don't return after sending a
signal.
* fhandler_termios.cc (fhandler_termios::line_edit): Trivial change to use
built-in bool types.
* fhandler_termios.cc (fhandler_termios::line_edit): After accept_input, handle
both potential error condition and pipe full conditions.
* fhandler_tty.cc (fhandler_pty_master::accept_input): Return -1 on error.
(fhandler_pty_master::write): Handle pipe full condition.
remove last char from readahead buffer if accept_input() fails.
* fhandler_tty.cc (fhandler_pty_master::accept_input): Return 0 and restore
readahead buffer when tty slave pipe is full.
whose second arguments are both the lenght and the return value.
* fhandler.cc (fhandler_base::read): Rework slightly to use second argument as
input/output. Tweak CRLF stuff.
(fhandler_base::readv): Accommodate fhandler_*::read changes.
* cygthread.h (cygthread::detach): Declare as taking optional handle argument.
(cygthread::detach): When given a handle argument, wait for the handle to be
signalled before waiting for thread to detach. Return true when signal
detected.
enum to allow the function to return an error.
* fhandler_console.cc (fhandler_console::read): Update the line_edit call to
use the new enum.
* fhandler_termios.cc (fhandler_termios::line_edit): Change return from an int
to an enum to allow the function to return an error. Put put_readahead call
before doecho for future patch.
* fhandler_tty.cc (fhandler_pty_master::write): Change to call line_edit one
character at a time, and stop if an error occurs.
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.
size is equal to the old one. Send SIGWINCH if slave connected to a pseudo
tty.
(fhandler_pty_master::ioctl): Do nothing if the new window size is equal to the
old one.
Rename _pid() to pid() throughout.
* Makefile.in: Compile some objects with -fomit-frame-pointer.
* cygwin.din: Reverse aliasing for _kill.
* syscalls.cc (_getpid_r): New function, implemented for newlib compatibility.
* shared.cc (open_shared): Remove reserving of memory since previous change
eliminate the need for this hack.
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.
already taken care of that.
* fhandler_console.cc (fhandler_console::open): Initialize handles to NULL.
(fhandler_console::close): Ditto. GNUify non-GNU formatted functions calls
throughout.
function.
(cygthread::operator new): Add defense debugging output.
(cygthread::cygthread): Add debugging output. Set name after thread has been
awakened to avoid a race.
(cygthread::exit_thread): Use handle operator rather than using ev directly.
(cygthread::exit_thread): Reorganize to provide debugging. Set __name to NULL.
* cygthread.h (cygself): Define.
* fhandler_tty.cc (fhandler_tty_master::init): Use cygself as argument so that
invoked thread can access its own info.
(process_output): Derive cygthread info of thread from thread argument.
* sigproc.cc (sigproc_init): Use cygself as argument so that invoked thread can
access its own info.
(wait_sig): Derive cygthread info of thread from thread argument.
* 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.
* fhandler.h: Move fcntl.h include here.
(fhandler_base::set_flags): Accept supplied_bin argument. Make non-inlined.
* dtable.cc (dtable::init_std_file_from_handle): Just use binmode from pc.
(reset_to_open_binmode): Use set_flags.
* cygwin.din (open): Avoid newlib wrapper.
(read): Ditto.
(unlink): Ditto.
(write): Ditto.
* fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument. Make
binmode decisions here.
(fhandler_base::open): Avoid using pc if it is NULL. Eliminate binmode logic.
Just call set_flags with binmode argument.
(fhandler_base::init): Call set_flags with binmode argument.
* fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto.
* fhandler_console.cc (fhandler_console::open): Ditto.
(fhandler_console::init): Force binary on open.
* fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode here.
Let it happen in base class.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open. Set return
value appropriately if unable to open.
* fhandler_proc.cc (fhandler_proc::open): Make sure flags are set before
open_status.
* fhandler_process.cc (fhandler_process::open): Ditto.
* fhandler_registry.cc (fhandler_registry::open): Ditto.
* fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default.
* fhandler_serial.cc (fhandler_serial::init): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
(fhandler_pty_master::open): Ditto.
* fhandler_virtual.cc (fhandler_virtual::open): Ditto.
* fhandler_windows.cc (fhandler_windows::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
* net.cc (fdsock): Ditto.
* path.cc (path_conv::check): Avoid checking for extension when error or
directory.
(set_flags): Set PATH_TEXT explicitly, when appropriate.
(mount_info::conv_to_win32_path): Use set_flags() to set path flags.
* path.h (PATH_TEXT): New enum.
(path_conv::binmode): Return appropriate constant based on binmode.
* pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY.
* syscalls.cc (setmode_helper): Make debugging message a little clearer.
(setmode): Set binmode via set_flags.
(LoadFuncEx2): Adapted from LoadFuncEx. Provides control of return value for
nonexistent function.
(NtQueryObject): Declare.
(IsDebuggerPresent): Declare via LoadFuncEx2 and always return true if not
available.
* debug.h (being_debugged): Just rely on IsDebuggerPresent return value.
* dtable.cc (handle_to_fn): New function.
(dtable::init_std_file_from_handle): Attempt to derive std handle's name via
handle_to_fn.
(dtable::build_fhandler_from_name): Fill in what we can in path_conv structure
when given a handle and path doesn't exist.
* fhandler.cc (fhandler_base::open): Don't set the file pointer here. Use
pc->exists () to determine if file exists rather than calling GetFileAttributes
again.
* fhandler.h (fhandler_base::exec_state_isknown): New method.
(fhandler_base::fstat_helper): Add extra arguments to declaration.
(fhandler_base::fstat_by_handle): Declare new method.
(fhandler_base::fstat_by_name): Declare new method.
* fhandler_disk_file (num_entries): Make __stdcall.
(fhandler_base::fstat_by_handle): Define new method.
(fhandler_base::fstat_by_name): Define new method.
(fhandler_base:fstat): Call fstat_by_{handle,name} as appropriate.
(fhandler_disk_file::fstat_helper): Accept extra arguments for filling out stat
structure. Move handle or name specific stuff to new methods above.
(fhandler_disk_file::open): Use real_path->exists rather than calling
GetFileAttributes again.
* ntdll.h (FILE_NAME_INFORMATION): Define new structure.
(OBJECT_INFORMATION_CLASS): Partially define new enum.
(OBJECT_NAME_INFORMATION): Define new structure.
(NtQueryInformationFile): New declaration.
(NtQueryObject): New declaration.
* path.cc (path_conv::fillin): Define new method.
* path.h (path_conv::fillin): Declare new method.
(path_conv::drive_thpe): Rename from 'get_drive_type'.
(path_conv::volser): Declare new method.
(path_conv::volname): Declare new method.
(path_conv::root_dir): Declare new method.
* syscalls.cc (fstat64): Send real path_conv to fstat as second argument.
where appropriate, throughout. Remove unneeded exceptions.h, where
appropriate, throughout. Remove unneeded perprocess.h, where appropriate,
throughout.
* Merged cygwin_daemon into head minus the new shm and ipc exports.
2002-02-28 Robert Collins <rbtcollins@hotmail.com>
* fhandler_tty.cc (fhandler_tty_slave::open): More debugging.
(fhandler_tty_slave::read): Fix printf type for the handle.
* tty.cc (tty::common_init): Add a FIXME for security.
2002-01-29 Robert Collins <rbtcollins@hotmail.com>
* Makefile.in (OBJS): Remove duplicate localtime.o.
2002-01-17 Robert Collins <rbtcollins@hotmail.com>
* cygserver.cc (check_and_dup_handle): Consolidate the two variants for
simplicity.
Add Some basic debug output.
(client_request_attach_tty::serve): Use the new debug_printf for clarity.
Mark the duplicated handles as inheritable - fixup_after_fork() doesn't reopen
tty's.
2002-01-16 Robert Collins <rbtcollins@hotmail.com>
* cygserver.cc (transport): Correct scope.
(client_request_attach_tty::serve): Add more debug information.
Fix erroneous use of transport instead of conn.
* cygserver_transport_pipes.cc (transport_layer_pipes::close): More debug.
(transport_layer_pipes::read): Ditto.
(transport_layer_pipes::write): Ditto.
(transport_layer_pipes::impersonate_client): Ditto.
Mon Oct 8 7:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
* cygserver.cc (server_request::process): Rename client_request_shm_get to
client_request_shm.
* cygserver_process.cc (process_cache::add): Rename to add_task.
Use process_cleanup instead of process_request.
(process_cache::remove_process): New method.
(process::process): Initialize new members.
(process::~process): New member.
(process::cleanup): New method.
(process::add_cleanup_routine): New method.
(process_request::process): Rename to process_cleanup.
Call the process object's cleanup method and then delete it.
(process_process_param::request_loop): Remove the signalling process.
* cygserver_shm.cc: Globally rename client_request_shm_get to client_request_shm.
(client_request_shm_get::serve): Handle attach request counting.
* cygserver_shm.h: Globally rename client_request_shm_get to client_request_shm.
(class shm_cleanup): New class.
* shm.cc: Globally rename client_request_shm_get to client_request_shm.
(client_request_shm::client_request_shm): New constructor for attach requests.
(shmat): Use it.
* include/cygwin/cygserver_process.h (class process_request): Rename to
process_cleanup.
(class cleanup_routine): New class.
(class process): New members and methods to allow calling back when the process
terminates.
Thu Oct 4 14:12:00 2001 Robert Collins <rbtcollins@hotmail.com>
* cygserver.cc (request_loop): Make static.
(main): Use new cache constructor syntax.
Start cache worker threads.
Cleanup the cache at shutdown.
* cygserver_process.cc: Run indent.
(process_cache::process_cache): Add a trigger to use when adding a process.
(process_cache::process): Move process_entry to process.
Insert at the end of the list.
Trigger the request loop when new process's inserted.
(process_cache::process_requests): Do it.
(process_cache::add): New method.
(process_cache::handle_snapshot): New method.
(process::process): Merge in the process_entry fields.
(process::handle): Make a stub function.
(process::exit_code): New method.
(process_request::process): New method.
(process_process_param::request_loop): New method.
* cygserver_shm.cc: New header dependency - threaded_queue.h.
* threaded_queue.cc (threaded_queue::cleanup): Clearer messages.
(queue_process_param::stop): Short spinlock on interruptible threads.
* threaded_queue.h (class threaded_queue): New constructor.
* include/cygwin/cygserver_process.h (process_request): New class.
(process_entry): Remove.
(process): Merge in process_entry.
(process_cache): Inherit from threaded_queue.
Tue Oct 2 23:24:00 2001 Robert Collins <rbtcollins@hotmail.com>
* cygserver.cc (class server_process_param): Use new constructor syntax.
* cygserver_process.cc (process_cache::~process_cache): New function.
* threaded_queue.cc: Define condition debug_printf.
Run indent.
(threaded_queue::cleanup): Move queue_process_param guts to a method.
(threaded_queue::process_requests): Ditto.
(queue_process_param::queue_process_param): New method.
(queue_process_param::~queue_process_param): Ditto.
(queue_process_param::start): Ditto.
(queue_process_param::stop): Ditto.
* threaded_queue.h (class queue_process_param): Add support for
interruptible request loops.
* cygwin/include/cygwin/cygserver_process.h (class process_cache): Add
destructor.
Tue Oct 2 23:24:00 2001 Robert Collins <rbtcollins@hotmail.com>
* cygserver_client.cc: New flag allow_daemon to disable the daemon completely.
(cygserver_request): Check it.
(cygserver_init): Ditto.
* environ.cc (parse_thing): Add (no)daemon option.
Tue Oct 2 23:00:00 2001 Robert Collins <rbtcollins@hotmail.com>
* shm.cc: Update to handle include changes from HEAD.
Tue Oct 2 16:06:00 2001 Robert Collins <rbtcollins@hotmail.com>
* Makefile.in: Remove cygserver_shm.o from cygwin1.dll.
Rename cygserver_shm_outside.o to cygserver_shm.o.
* cygserver.cc (server_request::process): Use the new client_request
constructor.
* cygserver_client.cc: Remove the #ifdef's stubs for the server method
within cygwin.
(client_request_attach_tty::client_request_attach_tty): Use the new
client_request constructor.
(client_request_shutdown::client_request_shutdown): Ditto.
(client_request::client_request): Ditto.
* cygserver_shm.cc (client_request_shm_get::serve): Remove the
#ifdef'd stub for in-cygwin builds.
(client_request_shm_get::client_request_shm_get): Use the new
client_request constructor, and remove the in-cygwin variants.
* cygserver_shm.h (class client_request_shm_get): #ifndef test the
serve method - it's only used in cygserver.
* shm.cc (client_request_shm_get::client_request_shm_get): New function.
* include/cygwin/cygserver.h (request_header): New constructor.
(class client_request): Use it.
New constructor accepting the header size.
#ifndef test the server method - it's only used within cygserver.
(client_request_get_version): #ifdef test the server method.
(client_request_shutdown): Ditto.
(client_request_attach_tty): Ditto.
Tue Oct 2 9:57:00 2001 Robert Collins <rbtcollins@hotmail.com>
* Makefile.in: add threaded_queue.o to cygserver.exe.
* cygserver.cc: Include threaded_queue.h
(class server_request): Inherit from queue_request.
(class server_process_param): Inherit from queue_process_param.
(class server_request_queue): Inherit from threaded_queue.
(request_loop): Adjust for new types.
(server_request_queue::process_requests): Remove guts to
threaded_queue::process_requests.
(server_request::server_request): Adjust for new types.
(worker_function): Delete.
(server_request_queue::create_workers): Delete.
(server_request_queue::cleanup): Delete.
(server_request_queue::add): Move guts to threaded_queue::add.
* threaded_queue.cc: New file.
* threaded_queue.h: New file.
Mon Oct 1 12:38:00 2001 Robert Collins <rbtcollins@hotmail.com>
* cygserver.cc (client_request::serve): New function.
* cygserver_process.cc: Inlude <pthread.h> for pthread_once.
(process_cache::process_cache): Initialise a crtiical section for write access.
(process_cache::process): Use the critical section. Also add missing entries to
the cache.
(do_process_init): New function to initalise class process static variables.
(process::process): Ensure that the process access critical section is
initialised.
(process::handle): Close the handle of old process's when they have terminated
and we are returning the handle for a process with the same pid.
* cygserver_shm.cc: Run indent.
Include cygserver_process.h to allow process cache functionality.
(client_request_shm_get::serve): New parameter for process cache support.
Use the process cache, not OpenProcess to get a handle to the originating process.
Fix a handle leak with token_handle.
* cygserver_shm.h (class client_request_shm_get): Update ::serve for process
cache support.
* cygserver_transport_pipes.cc: Redefine debug_printf to be conditional on DEBUG.
* include/cygwin/cygserver.h: Do not implement client_request::serve in the
header.
* include/cygwin/cygserver_process.h (class process_cache): Add a write access
critical section to prevent races when requests from a multithreaded
application arrive.
Sun Sep 30 23:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
* Makefile.in: Add cygserver_process.o to cygserver.exe.
* cygserver.cc: Include signal.h and cygwin_version.h.
Define debug_printf as a macro.
Define DEBUG to a value.
(client_request_attach_tty::serve): Add beginning of process cache support.
Change from #ifdef DEBUG to work with new DEBUG style.
(client_request_get_version::serve): Add beginning of process cache support.
(class server_request): New prototype for support of process cache.
(class queue_process_param): New class to allow request loop threading.
(class server_request_queue): Add beginning of process cache support.
Allow request loop threading.
(request_loop): Thread function for request loops.
(server_request_queue::process_requests): Initiator for threaded request loops.
(client_request_shutdown::serve): Add beginning of process cache support.
(server_request::server_request): Ditto.
(server_request::process): Use debug_printf. Add beginning of process cache
support.
(server_request_queue::cleanup): Kill off any request loop threads.
(server_request_queue::add): Add beginning of process cache support.
(handle_signal): Trigger a shutdown.
(main): Print out some useful info at startup - version, date time.
Add process cache support.
Spawn a separate thread for the transport request loop, thus allowing concurrent
support for multiple transports.
* cygserver_client.cc (client_request_get_version::serve): Add process cache
support.
(client_request_attach_tty::serve): Add process cache support.
(client_request_shutdown::serve): Add process cache support.
* cygsserver_process.cc: New file with the process cache support.
* cygserver_shm.cc: Redefine debug_printf to allow conditional output.
* cygwin.din: Export shmdt().
* shm.cc: Run indent.
Update FIXME's.
(shmdt): New function.
* include/cygwin/cygserver.h (class client_request): Add process cache support.
(class client_request_get_version): Ditto.
(class client_request_shutdown): Ditto.
(class client_request_attach_tty): Ditto.
* include/cygwin/cygserver_process.h: New header for process cache support.
Sun Sep 30 8:52:00 2001 Robert Collins <rbtcollins@hotmail.com>
* include/cygwin/cygserver_transport.h: Add copyright header.
* include/cygwin/cygserver_transport_pipes.h: Ditto.
* include/cygwin/cygserver_transport_sockets.h: Ditto.
Sat Sep 29 20:40:00 2001 Robert Collins <rbtcollins@hotmail.com>
* Makefile.in: Add cygserver_transport_sockets.o to DLL_OFILES.
Add cygserver_transport_sockets_outside.o to cygserver.exe.
* cygserver.cc: Include new include files.
* cygserver_client.cc: Ditto.
* cygserver_shm.h: No need to include <sys/socket.h> now.
* cygerver_transport.cc: Include new include files.
(transport_layer_base::transport_layer_base): Strip back to a stub.
(transport_layer_base::listen): Ditto.
(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_pipes.cc: Include new header
"cygwin/cygserver_transport_pipes.h".
* cygserver_transport_sockets.cc: New file.
* dcrt0.cc: No need to include <sys/socket.h> now.
* fhandler_tty.cc: Ditto.
* tty.cc: Ditto.
* include/cygwin/cygserver_transport.h: Strip the base class to a stub.
Remove the cygserver_transport_pipes class.
* include/cygwin/cygserver_transport_pipes.h: New file.
* include/cygwin/cygserver_transport_sockets.h: New file.
Tue Sep 25 16:22:00 2001 Robert Collins <rbtcollins@hotmail.com>
* autoload.cc: Add dynamic load statement for 'ImpersonateNamedPipeClient'.
* Makefile.in: Add new object files, and build instructions for cygserver.exe.
* cygwin.din: Export ftok, shmat, shmctl and shmget.
* dcrt0.cc: Additional includes for cygserver support.
(dll_crt0_1): Initialise the cygserver client.
* fhandler.h (fhandler_tty): New method cygserver_attach_tty.
* fhandler_tty.cc: Additional includes for cygserver support.
(fhandler_tty_slave::open): Attempt to use the cygserver when obtaining
handles from the parent process. On failure or 9x use the current method.
(fhandler_tty_slave::cygserver_attach_tty): New function.
* fork.cc (fork_child): Fixup shm memory mapped areas.
* pinfo.h: Declare fixup_shms_after_fork().
* security.h: Declare alloc_sd().
* tty.cc: Additonal includes to support cygserver.
(tty::common_init): Don't allow others to open us if the cygserver is running.
* winsup.h: Declare cygserver_running.
* cygserver.cc: New file.
* cygserver_client.cc: New file.
* cygserver_shm.cc: New file.
* cygserver_shm.h: New file.
* cygserver_transport.cc: New file.
* cygserver_transport_pipes.cc: New file.
* ipc.cc: New file.
* shm.cc: New file.
* include/cygwin/cygserver.h: New file.
* include/cygwin/cygserver_transport.h: New file.
* include/sys/ipc.h: New file.
* include/sys/shm.h: New file.
2002-02-28 Robert Collins <rbtcollins@hotmail.com>
* thread.cc (semaphore::TryWait): Set errno as required by posix 1003.1.
(__sem_wait): Ditto.
(__sem_trywait): Ditto.
muto. Use this argument to construct static storage.
* cygheap.cc (cygheap_init): Reflect above change.
* exceptions.cc (events_init): Ditto.
* malloc.cc (malloc_init): Ditto.
* path.cc (cwdstuff::init): Ditto.
* cygheap.h (cwdstuff): Change name of lock element to make it less generic.
* path.cc (cwdstuff::get_hash): Ditto.
(cwdstuff::get_initial): Ditto.
(cwdstuff::set): Ditto.
(cwdstuff::get): Ditto.
* sigproc.cc (proc_subproc): Ditto.
* debug.cc (lock_debug): Change to method. Use method rather than macro
throughout.
* tty.h (tty_min::kill_pgrp): Declare new method.
* fhandler_termios.cc (tty_min::kill_pgrp): New method.
(fhandler_termios::line_edit): Use new method for killing process.
* dcrt0.cc (do_exit): Ditto.
* dtable.cc (dtable::get_debugger_info): New method for inheriting dtable info
from a debugger.
* tty.cc (tty_init): Attempt to grab file handle info from parent debugger, if
appropriate. # dtable.cc (dtable::stdio_init): Make this a method.
(dtable::init_std_file_from_handle): Don't set fd unless it's not open.
(dtable::build_fhandler_from_name): Move name setting to
dtable::build_fhandler.
(dtable::build_fhandler): Add win32 name parameter.
* dcrt0.cc (dll_crt0_1): Change to use dtable stdio_init.
* dtable.h (dtable): Reflect build_fhandler parameter change.
* mmap.cc (mmap_record::alloc_fh): Don't set name parameter in build_fhandler.
* net.cc (fdsock): Remove set_name call since it is now handled by
build_fhandler.
* sigproc.cc (proc_subproc): Release muto as early as possible.
argument.
* fhandler_serial.cc (fhandler_serial::fhandler_serial): Ditto.
(fhandler_serial::open): Avoid else when previous clause is a return().
* path.cc (get_devn): Alias /dev/ttyS0 -> /dev/com1, etc.
(get_device_number): Reallow standalone "com1" as a valid name for /dev/com1.
SNDCTL_DSP_GETBLKSIZE operation. Remove obsolete 'name' arg from fhandler_*
constructors throughout.
* winsup.h (winsock_active): New macro.
(winsock2_active): Ditto.
* autoload.cc (wsock_init): Use new macros to decide if winsock or winsock2 is
loaded.
(nonexist_wsock32): Dummy function to force winsock load.
(nonexist_ws2_32): Dummy function to force winsock2 load.
* fhandler.h (fhandler_socket::fstat): Declare new method. Currently unused.
* fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Check that
winsock2 is active before trying WSADuplicateSocketA.
(fhandler_socket::fixup_after_fork): Add extra check for winsock2_active.
Otherwise use iffy procedures for Windows 95.
(fhandler_socket::fixup_after_exec): Add debugging.
(fhandler_socket::dup): Add debugging.
(fhandler_socket::fstat): New method.
(fhandler_socket::set_close_on_exec): Attempt to perform iffy stuff on Windows
95.
* errno.cc (_sys_nerr): Work around compiler strangeness.
* pinfo.cc (winpids::add): Add extra element at end of allocated array for
setting to NULL.
(winpids::enumNT): Ditto.
(winpids::init): Don't modify pidlist if it hasn't been allocated
(possibly due to malloc problem).
as non-inheritable for debugging purposes in case there is a subsequent fork or
exec.
* fhandler_tty.cc (fhandler_tty_common::fixup_after_fork): Allow fork_fixup to
call ProtecHandle.
* fork.cc (vfork): Add debugging statements.
* path.cc (get_device_number): Make static. Rewrite to inspect both unix and
windows paths.
(get_raw_device_number): Just check for parts of raw device that we care about.
(get_devn): New function, pulled from get_device_number.
(win32_device_name): Accomodate arg changes to get_device_number.
(mount_info::get_device_number): Call get_device_number on translated Windows
path.
* spawn.cc (spawn_guts): Don't treat P_VFORK differently from P_NOWAIT. Add
handle to child's shared region to child so that it will be preserved if the
parent goes away.
* fhandler.h: Throughout, simplify to one open method for all fhandler classes,
requiring a path_conv first element.
* fhandler.cc (fhandler_base::open): Remove obsolete method. Generalize to
require path_conv * as first argument.
(fhandler_disk_file::open): Remove obsolete method.
(fhandler_disk_file::open): Use path_conv pointer rather than reference.
* fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Use new open method.
(fhandler_dev_clipboard::open): Accomodate new argument for open methods.
* fhandler_console.cc (fhandler_console::open): Ditto.
(fhandler_console::dup): Use new open method.
(fhandler_console::fixup_after_fork): Ditto.
(fhandler_console::fixup_after_exec): Ditto.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Accomodate new argument for open
methods.
* fhandler_floppy.cc (fhandler_dev_floppy::open): Ditto.
* fhandler_mem.cc (fhandler_dev_mem::open): Ditto.
* fhandler_random (fhandler_dev_random::open): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Ditto.
* fhandler_serial.cc (fhandler_serial::open): Ditto.
* fhandler_tape.cc (fhandler_dev_tape::open): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
(fhandler_pty_master::open): Ditto.
* fhandler_windows.cc (fhandler_windows::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Accomodate new
argument for open methods.
* syscalls.cc (_open): Ditto.
(stat_worker): Ditto.
operators to simplify testing for directory and attributes, throughout.
* path.h (path_conv::exists): New method.
(path_conv::has_attribute): Ditto.
(path_conv::isdir): Ditto.
(path_conv::DWORD &): New operator.
(path_conv::int &): Ditto.
* dir.cc (rmdir): Eliminate a goto.
* dtable.cc (dtable::build_fhandler): Accept opt and suffix info for
path_conv.check. Return fh == NULL on path_conv error. Pass unit to set_name
as appropriate.
(dtable::reset_unix_path_name): New method.
* dtable.h (dtable): Declare new method. Reflect arg changes to
build_fhandler.
* fhandler.cc (fhandler_disk_dummy_name): Eliminate.
(fhandler_base::set_name): Expect paths to be NULL. Build unix_path_name from
win32_path_name when it is a device.
(fhandler_base::reset_unix_path_name): New method.
(fhandler_base::raw_read): Report EISDIR when ERROR_INVALID_FUNCTION or
ERROR_INVALID_PARAMETER and reading a directory.
(fhandler_disk_file::fstat): Don't call stat_dev since we should now never be
calling fhandler_disk_file methods with devices.
(fhandler_base::fhandler_base): Clear {unix,win32}_path_name.
(fhandler_base::~fhandler_base): Always free {unix,win32}_path_name.
(fhandler_disk_file::fhandler_disk_file): Remove set_no_free_names kludge.
(fhandler_disk_file::open): Ditto.
* fhandler.h (fhandler_base::no_free_names): Eliminate.
(fhandler_base::set_no_free_names): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Don't set
unix_path_name here.
* path.cc (fchdir): Lock fd table throughout. Use new
dtable::reset_unix_path_name method to reset path.
* syscalls.cc (stat_worker): Reorganize to always call fstat method. Pass
path_conv method to fhandler_*::open.
(chroot): Elminate a goto.
(writepipe_exists): New class element.
(orig_pid): Ditto.
(id): Ditto.
(is_slow): Eliminate.
* pipe.cc (fhandler_pipe::set_close_on_exec): Set inheritance on
writepipe_exists, if it exists.
(fhandler_pipe::hit_eof): New method, modelled after tty.
(fhandler_pipe::dup): Duplicate writepipe_exists, if it exists.
(make_pipe): Set up a dummy event for pipes on windows 9x. The nonexistence
of this event means that the write side of the pipe has closed.
(_dup): Move to syscalls.cc
(_dup2): Ditto.
* dtable.cc (dtable::build_fhandler): Fill out set_names here, if appropriate.
* syscalls.cc (_open): Call set_names in build_fhandler.
(setclexec_pid): New function for marking saved handle as close-on-exec.
(delete_handle): New function.
(debug_fixup_after_fork): New function.
* debug.h: Declare new functions, remove obsolete ones.
* fork.cc (debug_fixup_after_fork): Call to cleanup close-on-exec handles.
* fhandler.cc (fhandler_disk_file::close): Minor reorg.
(fhandler_base::set_inheritance): Set flag appropriately for debugging when
close-on-exec so forked process can delete closed handles.
* tty.h (open_output_mutex): Eliminate unneeded argument.
(open_input_mutex): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): reflect open_*_mutex argument
changes.
* fhandler.h (fhandler_socket): Make saw_shutdown_* functions type bool.
* tty.cc (tty::get_event): Eliminate unneeded argument.
(tty::common_init): Reflect change to get_event. Events should always be
inherited.
* fhandler.h: Move definitions of O_NOSYMLINK, O_DIROPEN and
OLD_O_NDELAY from winsup.h to here. Add O_NONBLOCK_MASK define.
* fhandler_socket.cc (fhandler_socket::close): Add hack to allow
a graceful shutdown even if shutdown() hasn't been called by the
application. Add debug output.
(fhandler_socket::ioctl): Set fhandler's NONBLOCK flag according
to FIONBIO setting.
(fhandler_socket::fcntl): Use new O_NONBLOCK_MASK define. Actually
set `request' before using it.
* fhandler_tty.cc: Use new O_NONBLOCK_MASK define throughout.
(fhandler_tty_slave::ioctl): Set fhandler's NONBLOCK flag according
to FIONBIO setting.
(fhandler_pty_master::ioctl): Ditto.
* net.cc (wsock_event::prepare): Compare WSACreateEvent return code
with `WSA_INVALID_EVENT' according to MSDN.
* syscalls.cc (_read): Use new O_NONBLOCK_MASK define.
fhandler.h.
* fhandler.h (fhandler_base::get_inheritance): New method.
* fhandler_socket.cc (fhandler_socket::create_secret_event): Use proper
close-on-exec inheritance when creating.
(fhandler_socket::check_peer_secret_event): Create handle as non-inheritable.
* dtable.cc (dtable::dup_worker): Add debugging output.
(dtable::vfork_child_dup): Correctly set close_on_exec.
* fhandler.cc (fhandler_base::fork_fixup): Don't mess with handle if there is
no need to get it from the parent.
* fhandler_tty.cc (fhandler_tty_common::close): Add debugging output.
* fork.cc (fork_copy): Print more debugging info.
(fork_parent): Change order of arguments to accomdate buggy gcc.
(fork): Ditto.
* syscalls.cc (_unlink): Reorganize to try harder to delete file with
DeleteFile and to recover more gracefully if FILE_FLAG_DELETE_ON_CLOSE doesn't
work properly.
stopping.
* fhandler_console.cc (fhandler_console::fixup_after_fork): Don't set
controlling terminal if just inheriting a handle.
(fhandler_console::fixup_after_exec): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::init): Ditto.
* signal.cc (kill_worker): Set appropriate errno if proc_exists determines that
process does not really exist.
(_crealloc): Ditto.
* dcrt0.cc (dll_crt0_1): Default to always checking for executable for now.
* dtable.cc (dtable::not_open): Move method.
* dtable.h (dtable): Here.
* exceptions.cc (ctrl_c_handler): Don't expect process group leader to handle a
signal if it doesn't exist.
* fhandler.h (fhandler_base): Make openflags protected.
* localtime.c (tzsetwall): Check for __CYGWIN__ as well as __WIN32__.
* path.cc (path_conv::check): Add some comments. Change strcat to assignment.
* lib/_cygwin_S_IEXEC.cc (_cygwin_bob__): Eliminate.
* fhandler_tty.cc (fhandler_console::dup): Set controlling terminal if
necessary.
* fhandler_tty.cc (fhandler_tty_slave::dup): Ditto.
Throughout, change 'OutputStopped' to 'output_stopped', for consistency.
* dtable.cc (stdio_init): Set controlling tty if not set by stdio opens.
* exceptions.cc (ctrl_c_handler): Avoid special pgid checking if no tty is
associated with the process.
(Suggested by Tim Baker <dbaker@direct.ca>)
* external.cc (fillout_pinfo): Return actual tty number for ctty.
* fhandler_console.cc (get_tty_stuff): Set ctty when shared memory is
allocated. Accept flags input from open().
(set_console_ctty): New function.
(fhandler_console::open): Pass flags to get_tty_stuff and rely on this function
to set the ctty, if appropriate.
* fhandler_termios.cc (fhandler_termios::set_ctty): Move to tty_min class.
* fhandler_tty.cc (fhandler_tty_slave::open): Use tc field to access
set_ctty().
* tty.h (TTY_CONSOLE): Move to include/sys/cygwin.h.
(tty_min): Add set_ctty class here.
* include/sys/cygwin.h (TTY_CONSOLE): New home here.
* path.cc (symlink_info): Make contents an actual buffer. Pass more flags to
case_check.
(path_conv::check): Reorganize to do parsing based on posix path rather than
native path.
(symlink_info::check): Expect posix path as input. Translate to native path
here. Accept path_conv flags. Stop parsing if not a symlink regardless of
whether previous path was a symlink.
* fhandler.h (fhandler_base::set_open_status): New method. Stores original
open status.
(fhandler_base::get_open_status): New method. Retrieves original open status.
(fhandler_base::reset_to_open_binmode): New method.
* fhandler.cc (fhandler_base::open): Save open status.
(fhandler_base::init): Ditto.
* fhandler_clipboard.cc (fhandler_clipboard::open): Ditto.
* fhandler_console.cc (fhandler_console::open): Ditto.
* fhandler_dsp.cc (fhandler_dsp::open): Ditto.
* fhandler_dev_mem.cc (fhandler_dev_mem::open): Ditto.
* fhandler_dev_random.cc (fhandler_dev_random::open): Ditto.
* fhandler_serial.cc (fhandler_serial::open): Ditto.
* fhandler_tty_slave.cc (fhandler_tty_slave::open): Ditto.
* fhandler_tty_master.cc (fhandler_tty_master::open): Ditto.
* fhandler_dev_zero.cc (fhandler_dev_zero::open): Ditto.
* syscalls.cc (setmode): Rework so that 0 mode value causes reversion to open
state.
* fhandler_tty_slave.cc (fhandler_tty_slave::read): Use correct multiplier when
converting from deciseconds to milliseconds.