Commit Graph

604 Commits

Author SHA1 Message Date
Christopher Faylor 92e1969051 * debug.cc (add_handle): Issue warning on attempts to add the same handle more
than once.
* fhandler_tty.cc (fhandler_tty_slave::open): Protect some handles.
(fhandler_tty_common::close): Use proper name when closing handles.
(fhandler_pty_master::close): Don't close to_slave or from_slave since they've
already been closed earlier in the function.
* sigproc.cc (proc_subproc): Don't protect vchild->hProcess.  Expect that the
caller will do this, instead.
* tty.cc (tty_list::terminate): Use proper name when closing handles.
(tty::make_pipes): Protect some handles.
2000-10-17 01:42:04 +00:00
Christopher Faylor 166b2571ce * Makefile.in: Remove some obsolete stuff.
* dcrt0.cc (dll_crt0_1): Call signal_fixup_after_exec where appropriate.  Set
myself->uid from parent version.  Just use ThreadItem Init method.  Close or
store hexec_proc as appropriate.
(_dll_crt0): Store user_data->forkee here so that proper tests can be made
subsequently.
(do_exit): Remove hExeced stuff.
* environ.cc (environ_init): Accept environ count as well as environ pointer.
* environ.h: Reflect above change.
* pinfo.cc (pinfo_init): Ditto.  Accept environ count.
(fixup_in_spawned_child): Remove.
* spawn.cc (spawn_guts): Move signal code to dll_crt0_1.  Don't suspend execing
process since it is no longer necessary.  Store envc.
* exceptions.cc (signal_fixup_after_exec): New function.
(call_handler): Remove hExeced test.
* child_info.h (cygheap_exec_info): Store envc as well as envp.
(child_info_spawn): Store hexec_proc so that it can be closed in child.
* path.cc (normalize_posix_path): Avoid intermediate use of temporary cwd buf.
(normalize_win32_path): Ditto.
(cwdstuff::get_initial): Always set lock.
* sigproc.h: Remove hExeced.
* strace.cc (strace::vsprntf): Modify to accomodate for lack of hExeced.
* thread.cc (MTinterface::Init): Merge Init1 and ClearReent into this method.
(MTinterface::Init1): Eliminate.
(MTinterface::ClearReent): Eliminate.
* thread.h: Reflect above changes.
* include/sys/strace.h (strace): Make microseconds() public.  Make various
functions 'regparm', throughout.
* pinfo.h (_pinfo): Inline simple signal manipulation functions.  Requires
inclusion of thread.h which was removed from .cc files, where appropriate.
throughout.
* pinfo.cc: Eliminate signal manipulation functions.
(_pinfo::exit): Calculate total rusage for exiting process here.
* cygheap.cc (size2bucket): Eliminate.
(init_buckets): Ditto.
(_cmalloc): Calculate size and bits in a loop rather than going through a
function call.
(_crealloc): Use stored array index to calculate allocated size.
* spawn.cc (spawn_guts): Use _pinfo exit method to exit, calculating cpu usage.
2000-10-16 23:55:58 +00:00
Christopher Faylor 1dc16fc74b * exceptions.cc (set_console_handler): Don't allocate
console_handler_thread_waiter.  It is obsolete.
(ctrl_c_handler): Don't use console_handler_thread_waiter.
* path.cc (hash_path_name): Fix handling of relative names.  Make case
insensitive.
* path.h (suffix_info): Use initializers.
* pinfo.h (_pinfo): Avoid initializers for null case.
* resource.cc (fill_rusage): Zero rest of rusage structure.
* security.cc (set_process_privileges): Don't reopen parent process.  Just use
hMainProc.
* signal.cc (signal): Track when a signal handler has been used.
(sigaction): Ditto.
* sigproc.cc (pchildren): Use default initializer.
(zombies): Ditto.
(sigproc_terminate): Avoid closing handles that will be closed on exit anyway.
(wait_sig): Send signal to "parent" on EXECing, not FORKing.
(wait_subproc): Send SIGCHLD here rather than in proc_wait to avoid potential
muto conflicts.
* sigproc.h (sigthread): Don't initialize to zero.  It's the default.
* spawn.cc (spawn_guts): Fill in resources from exec parent prior to
termination.
* sync.h (muto): Don't initialize to zero.
* syscalls.cc (close_all_files): Use one lock around entire loop and call
fhandler close/release stuff directly.
(_read): Don't use ready_for_read if there are not signal handlers active.
* dcrt0.cc (dll_crt0_1): Fix display of "title".
(do_exit): Use pinfo exit method to exit.
(__api_fatal): Ditto.
* exceptions.cc (signal_exit): Ditto.
* fork.cc (fork_child): Remove debugging stuff.  Use pinfo_fixup_after fork in
place of exec_fixup_after_fork.
* pinfo.cc (pinfo_fixup_after_fork): New method.
(pinfo_fixup_in_spawned_child): Ditto.
(_pinfo::exit): New method.
(_pinfo::init): Remove recursion.  Detect pathological case where pinfo
structure already exists for new pid.
* pinfo.h (_pinfo): Reorganize slightly.  Add new method and new function
declarations.
* sigproc.cc (proc_exists): Previous simplification was a little to simple.
Try harder to detect if a process exists.
(proc_terminate): Use PID_EXITED setting to determine if process is still
around.
(WFSO): Remove debugging statement.
(WFMO): Ditto.
* spawn.cc (exec_fixup_after_fork): Eliminate.
(spawn_guts): Always set old_title to NULL.  Is it really needed?  Move
hexec_proc to pinfo.cc.  Call pinfo_fixup_in_spawned_child to eliminate handle
link after a spawn.
* include/sys/cygwin.h: Remove PID_NOT_IN_USE.  Add PID_EXITED.
2000-10-15 01:37:07 +00:00
Corinna Vinschen fdc614360f Forgot to commit ChangeLog 2000-10-14 08:56:17 +00:00
Corinna Vinschen 7d9688b793 * cygwin.din: Add symbol hstrerror.
* net.cc: Change meaning of member `s' of struct host_errmap.
        (set_host_errno): Fix error in loop condition.
        (hstrerror): Ditto.
        (herror): Add appropriate functionality.
        * include/netdb.h: Add declaration of hstrerror.
        * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 29.
2000-10-14 08:55:44 +00:00
Christopher Faylor aece55b982 * cygheap.cc (cygheap_fixup_in_child): Don't page round cygheap copied from
parent.
* dcrt0.cc (do_exit): Don't cleanup pinfo on exit.  That happens automatically
now.
* exceptions.cc (signal_exit): Ditto.
* fork.cc (fork_parent): Use stack_here value passed in from fork().
(fork): Figure out top of stack here and pass it to fork_parent.
* pinfo.cc (_pinfo::record_death): Eliminate.
* pinfo.h (_pinfo): Ditto.
* sigproc.cc (proc_exists): Simplify.
(proc_terminate): Ditto.
(remove_zombie): Don't cleanup pinfo stuff.
(wait_sig): Send subproc_ready signal whether execed or spawned.
* spawn.cc (spawn_guts): Always create subproc_ready event.  Use it for both
exec and spawn.
(_spawnve): Send proper mode to spawn_guts when mode != _P_OVERLAY.
2000-10-14 05:52:38 +00:00
Christopher Faylor cbe4c8e234 Add comment. 2000-10-14 01:03:01 +00:00
Christopher Faylor ee20f060a8 * dtable.cc (dtable::fixup_after_fork): Revert thinko below.
* pinfo.cc (set_myself): Show pid in initial strace line.
2000-10-13 03:13:59 +00:00
Christopher Faylor 1ec4f618fe * child_info: Bump child_info "version".
(child_info): Move some fields from child_info_spawn to here.
* cygheap.cc: Make cygheap pointers NOCOPY.
* dcrt0.cc (dll_crt0_1): Copy cygwin heap here regardless of whether we've been
forked or execed.
* dtable.cc (dtable::fixup_after_fork): Just release close-on-exec fds.
* exceptions.cc (stackdump): Respond to C warning.
* fork.cc: Reorganize to minimize stack copying.
(fork_child): New function.
(fork_parent): Ditto.
(sync_with_child): Don't suspend the forkee.
(sync_with_parent): Ditto.  Make into a function.
* heap.cc (heap_init): Add some debugging output.
* path.cc (path_conv::check): Add an assertion.
(has_suffix): Ditto.
* security.cc (get_pw_sid): Defend against NULL.
* sigproc.cc (proc_subproc): Fix debugging output.
(wait_sig): Ditto.
* strace.cc: Make statics NO_COPY throughout.
(strace::vsprntf): Defend against NULL.
2000-10-12 22:15:47 +00:00
Christopher Faylor ec300c9979 * errno.cc (seterrno_from_win_error): Fix debugging output.
* fhandler.cc (fhandler_base::fstat): Move to inline method in fhandler.h.
(fhandler_base::set_io_handle): Ditto.
* fhandler.h (fhandler_base): Make some methods inline.
* fhandler_console.cc (fhandler_console::write_normal): Make buffer larger.
* sigproc.h (sigframe::sigframe): Actually use set ebp parameter correctly.
* spawn.cc (spawn_guts): Set dwProcessId when exec'ing.  Just exit immediately
after reparenting.
* syscalls.cc: Sprinkle sigframe stuff throughout.
* wait.cc (wait4): Set signal frame here.
* dcrt0.cc (__api_fatal): Don't rely on small_printf to display errors.  Always
display problems to the console, if possible.
2000-10-12 04:38:29 +00:00
Christopher Faylor e62ae31192 * path.cc (cwdstuff::get): Set EINVAL when length is zero. 2000-10-10 19:24:32 +00:00
Christopher Faylor dc7f5226eb * path.cc (mount_info::cygdrive_posix_path): Handle e:foo construction
correctly.
2000-10-09 18:10:53 +00:00
Corinna Vinschen 44e939882a * fhandler_mem.cc (fhandler_dev_mem::fhandler_dev_mem): Fix debug output. 2000-10-09 14:49:25 +00:00
Corinna Vinschen 21fdffa58a * fhandler_mem.cc: Eliminate unused include statements.
(fhandler_dev_mem::fhandler_dev_mem): Check for 9X/ME.
2000-10-09 14:02:25 +00:00
Corinna Vinschen 42f1b6c544 * fhandler.h (fhandler_dev_mem): Erase member `init_phase' and
member function `init'.
        * fhandler_mem.cc: Add typedefs for NT internal data types
        `SYSTEM_INFORMATION_CLASS' and `SYSTEM_BASIC_INFORMATION'.
        Add prototype for `NtQuerySystemInformation' function.
        (fhandler_dev_mem::fhandler_dev_mem): Takes over initialization task
        from `init'. Use `NtQuerySystemInformation' function to evaluate the
        size of physical memory instead of interval search.
        (fhandler_dev_mem::init): Eliminated.
        (fhandler_dev_mem::open): Don't call `init'.
        (fhandler_dev_mem::read): Eliminate check for `init_phase'.
        (dummy_autoload): Add load statement for `NtQuerySystemInformation'.
2000-10-09 13:19:41 +00:00
Christopher Faylor 164a681ca5 * dtable.cc (set_std_handle): Use std_consts array to control SetStdHandle
settings.
(dtable::fixup_after_fork): Ditto.
* exceptions.cc (set_sig_errno): Remove some debugging output.
* path.cc (path_conv::check): Don't OR need_directory with flags sent to
symlink_info::check.
(symlink_info::check): Use PATH_ALL_EXEC to determine when a file is
executable.
* path.h (path_types): Add PATH_ALL_EXEC.
(isexec): Use PATH_ALL_EXEC so that cygexec types will be considered
executable.
* pinfo.h (_pinfo): Add a process handle that is kept open throughout the life
of a cygwin pid.
* sigproc.cc (proc_exists): Remove hopefully obsolete stuff.
(proc_subproc): Set up process handle that is kept open throughout the life of
a cygwin pid.  Reorganize PROC_WAIT stuff to use common code.
(proc_terminate): Close pid lifetime process handle.
(checkstate): Cleanup.
(stopped_or_terminated): Move zombie cleanup.
(remove_zombie): To here.
* spawn.cc (spawn_guts): Reorganize reparenting code for 1247th time.
2000-10-09 02:53:44 +00:00
Christopher Faylor 57bf29e825 * fhandler.h (fhandler_base): Remove obsolete _rpos and _rsize elements.
* fhandler.cc (fhandler_base::open): Ditto.
* fhandler.cc (fhandler_base::fhandler_base): Ditto.
(fhandler_base::read): Ditto.  Add more debugging output.  Don't issue a \r
when \r\n detected.
* pipe.cc (make_pipe): Streamline slightly.  Make debug output more
interesting.
* strace.cc (strace::vsprintf): Use __progname where appropriate to distinguish
strace output when exec'ing.
2000-10-07 18:12:11 +00:00
Corinna Vinschen 4ea34a6850 * fhandler.h (fhandler_dev_mem): Add methods mmap, munmap and msync.
Add `unit' member.
        * fhandler_mem.cc (fhandler_dev_mem): Initialize `unit' as well.
        (init): Care for differences between /dev/mem, /dev/kmem (not
        implemented yet) and /dev/port.
        (open): Change debug message to reflect the device.
        (mmap): New function.
        (munmap): Ditto.
        (msync): Ditto.
        (fstat): Use unit when setting st_dev in stat structure.
        * mmap.cc (mmap): Handle MAP_ANONYMOUS flag.
        Change error handling slightly.
        * path.cc (get_device_number): Handle /dev/port.
2000-10-07 17:35:36 +00:00
Christopher Faylor 7aadaf0f7e * syscalls.cc (_read): Behave properly when passed previous version of
O_NDELAY.  Fix up debugging output.
2000-10-07 03:25:38 +00:00
Christopher Faylor 829425c9fd * net.cc (set_socket_inheritance): Rename from duplicate_socket. Use NT
specific call when appropriate.
(__set_winsock_errno): Rename from set_winsock_errno.  Accept function and line
as arguments.
* path.cc (path_conv::check): Continue the neverending battle to make cygwin
properly understand that path specs ending in a slash require that the path
refer to a directory.  Windows does not do this by default.
(symlink_info::check): Remove ENOTDIR test.  Move it to path_conv::check.
* path.h: Remove obsolete constant.
* winsup.h (set_winsock_errno): New macro.
2000-10-06 19:11:14 +00:00
Corinna Vinschen d12eba25a5 =====================================
These changes require rebuilding all.
        =====================================
        * fhandler.h: Add mmap(), munmap() and msync() to fhandler_base
        and fhandler_disk_file.
        * mmem.cc (mmap): Eliminated device dependent implementation details.
        These are moved to the appropriate fhandler class.
        (munmap): Ditto.
        (msync): Ditto.
        (fhandler_base::mmap): New method.
        (fhandler_base::munmap): Ditto.
        (fhandler_base::msync): Ditto.
        (fhandler_disk_file::mmap): Ditto.
        (fhandler_disk_file::munmap): Ditto.
        (fhandler_disk_file::msync): Ditto.
2000-10-05 13:07:02 +00:00
Christopher Faylor 4e6a4ea8e8 * net.cc: General cleanup.
(fdsock): Return pointer to created fhandler_socket.
(cygwin_socket): Use pointer returned by fdsock.  Return correct errno when fd
< 0.
2000-10-05 05:57:00 +00:00
Christopher Faylor a5855dc341 * exceptions.cc (interruptible): Add extra debugging.
* sigproc.h (wait_sig): Fill in frame pointer, by default, prior to calling or
suffer confusion due to September 7 change below.
2000-10-05 04:53:17 +00:00
Christopher Faylor 1daf97f97e * include/netinet/tcp.h: Remove winsock.h include.
* include/sys/cygwin.h: Move windows specific reference within conditional.
2000-10-05 03:12:36 +00:00
Corinna Vinschen 95436d7cdb * include/sys/mman.h: Add missing MAP_FAILED macro. 2000-10-04 23:17:01 +00:00
Corinna Vinschen f4f898aca0 * fhandler.h (fhandler_dev_mem): Add method `init'. Add members
`mem_size' and `init_phase'.
        * fhandler_mem.cc (init): New function to figure out the size of
        the physical memory.
        (open): Add checking for illegal flags. Change usage of access mode.
        (write): Add intended functionality.
        (read): Add parameter checking. Eliminate page size constant. Use
        getpagesize() instead. Don't touch errno and don't create debug output
        while init() is running.
        (lseek): Add bounds checking. Fix SEEK_END.
        (fstat): Eliminate page size constant. Use getpagesize() instead.
        (dup): Add intended functionality.
2000-10-04 17:08:46 +00:00
Corinna Vinschen 52b5a97156 * dcrt0.cc: Add LoadDLLFunc statement for RegEnumValueA().
* net.cc: Change comments related to get_ifconf.
        (get_2k_ifconf): Eliminate `type' variable. Eliminate `sa' parameter.
        (get_nt_ifconf): Ditto.
        (get_9x_ifconf): Ditto. Rewritten.
        (get_ifconf): Chage calls to OS specific functions.
2000-10-02 20:21:47 +00:00
Christopher Faylor 17e8632267 * signal.cc (sigaction): Allow new action == oldaction. 2000-10-02 19:19:21 +00:00
Corinna Vinschen a26fb3150d * fhandler_mem.cc: Load ntdll functions via autoload method.
(load_ntdll_funcs): Eliminated.
2000-10-02 09:07:50 +00:00
Corinna Vinschen 2f696b4bdb * fhandler_mem.cc (load_ntdll_funcs): Add missing __stdcall qualifiers. 2000-10-02 08:31:07 +00:00
Christopher Faylor 9fc09d00f7 * cygheap.cc (cygheap_init): Born again function.
(_cmalloc): Reorganize to accomodate muto locking.
(_cfree): Use muto lock to avoid multi-thread problems.
* cygheap.h (incygheap): Just use cygheap_max to find upper cygwin heap bounds.
* dcrt0.cc (dll_crt0_1): Reinstitute cygheap_init call.
* path.cc (getcwd): Just return cwdstuff::get result, allowing correct handling
of negative length.
(cwdstuff::get): Malloc a buffer if one is not available.
2000-10-02 02:26:04 +00:00
Corinna Vinschen 51c22a5c86 * Makefile.in: Add fhandler_mem.o to the dependencies.
* dtable.cc (dtable::build_fhandler): Add case for FH_MEM.
        * fhandler.h: Add FH_MEM device type.  Add class fhandler_dev_mem.
        * fhandler_mem.cc: New file. Implementation of class fhandler_dev_mem.
        * path.cc: Add /dev/mem to windows_device_names.
        (get_device_number): Add FH_MEM type.
2000-10-01 01:02:40 +00:00
Christopher Faylor 8d82847a29 * cygheap.cc (init_cheap): Set aside space for heap walk pointer.
(_csbrk): Make logic for detecting when to alloc cognizant of initialization
condition.
(_cmalloc): Use a structure to hold bucket size and heap chain pointer.  Store
pointer to next freed block in bucket size location so that it will be easy to
see if a block is allocated.
(_cfree): Store pointer to next freed block in bucket size location.
(_crealloc): Use macro to retrieve bucket size.
(cygheap_init): Eliminate.
(cygheap_fixup_in_child): Add second argument to determine if we were execed or
not.  In execed case, walk the heap, cleaning up any orphaned blocks.
* cygheap.h: Add a "MAX" value to cygheap_types.  Remove cygheap_init
declaration.  Accomodate new argument to cygheap_fixup_in child.
* fork.cc (fork): Accomodate extra argument to cygheap_fixup_in_child.
* dcrt0.cc (dll_crt0_1): Ditto.  Remove call to cygheap_init.
2000-09-30 04:54:11 +00:00
Christopher Faylor 90fe77395a * path.cc (symlink_info::check): Set executable bit for a file if the first two
characters are 'MZ' to mirror spawn_guts check.
2000-09-30 01:56:40 +00:00
Corinna Vinschen 84ecbb38d6 * winsup.h: Add `winME' to os_type symbols.
* dcrt0.cc (set_os_type): Identify Windows ME systems.
        * (host_dependent_constants::init): Care for winME.
        * uname.cc (uname): Ditto.
2000-09-30 01:38:13 +00:00
Corinna Vinschen 7326d4e4b1 * net.cc (get_ifconf): Code cleanup. Split. Call os dependent
subfunctions instead.
        (get_9x_ifconf): New function for 9X systems, called by get_ifconf.
        (get_nt_ifconf): New function for NT systems, called by get_ifconf.
        (get_2k_ifconf): New function for W2K systems, called by get_ifconf.
2000-09-28 06:34:38 +00:00
Christopher Faylor e564846577 * spawn.cc (spawn_guts): Attempt to accomodate archaic windows quoting
mechanism when dealing with '\' and '"'.
2000-09-27 05:12:09 +00:00
Christopher Faylor 4eafa56ec2 * dcrt0.cc (quoted): Fix problem where ' quoted strings were skipped.
* fhandler.h (fhandler_socket::~fhandler_socket): Delete declaration.
* net.cc: Remove unnecessary "number_of_sockets" usage.
(fhandler_socket::fhandler_socket): Ditto.
(fhandler_socket::~fhandler_socket): Delete definition.
* spawn.cc (spawn_guts): Force first argument passed to CreateProcess as a
command line to be windows style.
2000-09-26 00:52:21 +00:00
Christopher Faylor fb5956da13 * spawn.cc (av::dup_maybe): Make function void rather than void *.
* environ.cc (environ_init): Remember to reparse CYGWIN if envp is
supplied.
* heap.cc (_sbrk): Remember frame for signal handling.
* syscalls.cc (read_handler): Eliminate.
(_read): Move read_handler code here.  Reorganize for one path through
'ready_for_read'.
2000-09-25 16:36:12 +00:00
Christopher Faylor b963175618 * spawn.cc (spawn_guts): Use actual program argument passed in for argv[0] as
originally suggested by Kazuhiro Fujieda <fujieda@jaist.ac.jp>.
2000-09-19 13:48:52 +00:00
Christopher Faylor 6e604fb15d * path.h: Create new input path flag PATH_NEEDDIR.
* path.cc (path::check): Detect trailing slash before converting to windows
path.  Tell symlink_info::check to check for directory if one is found.
(symlink_info::check): Set errno when path is not a directory if pflags &
PATH_NEEDDIR.
2000-09-19 03:22:45 +00:00
Christopher Faylor a3ad824178 * fhandler_tty.cc (fhandler_tty_slave::write): Correct typo which caused
resetting of windows error to ERROR_IO_DEVICE to be ignored.
2000-09-18 23:46:10 +00:00
Christopher Faylor 9a02bdb58c * path.cc (mount_info::read_mounts): Don't delete mount entries of which mount
points have the cygdrive prefix.
* (mount_info::add_reg_mount): Properly catch errors on registry operations.
* (mount_info::write_cygdrive_info_to_registry): Ditto.
* (mount_info::del_reg_mount): Cosmetic changes to be consistent with other
methods.
* (mount_info::add_item): Check arguments more precisely.  Increment nmounts
only when registry operations succeed.
2000-09-18 16:42:28 +00:00
Christopher Faylor ca7ea5a6e7 * exceptions.cc (interruptible): Return 0 if given an address in uncommitted
memory.
2000-09-18 02:20:42 +00:00
Egor Duda a12b2260d0 * signal.cc (sleep): If interrupted by signal, return the
requested time minus the time actually slept.
2000-09-16 13:19:52 +00:00
Christopher Faylor f9f2ed0e2b * exceptions.cc (handle_exceptions): Just "core dump" if SIGSEGV in signal
thread.
* external.cc (fillout_pinfo): Fix compiler warning.
* sigproc.h: Eliminate special asm naming for sig_dispatch_pending.
* sigproc.cc (sig_send): Remove debugging statements.
2000-09-16 02:36:11 +00:00
Christopher Faylor 4f46dbc790 Commit change mentioned in ChangeLog. 2000-09-13 19:57:36 +00:00
Christopher Faylor 99d7d12af0 * spawn.cc (av): Hide 'calloced' field and limit cstrduping to class methods
only.
(spawn_guts): Use methods for manipulating most newargv stuff.
* child_info.h (child_info_spawn::~child_info_spawn): Avoid memory leaks in
cygheap.
* spawn.cc (spawn_guts): Ditto.
* dcrt0.cc (quoted): Return next character after a quoted string when not doing
special quote processing.  Also ensure that non-NULL is returned in all circumstances.
* spawn.cc (spawn_guts): Ensure that argv[0] is correctly set to the full path
when a script is detected.  Suggested by Kazuhiro Fujieda
<fujieda@jaist.ac.jp>.
2000-09-13 19:57:00 +00:00
Christopher Faylor 858f524917 * external.cc (fillout_pinfo): Handle explicit pids correctly. 2000-09-13 02:35:05 +00:00
Christopher Faylor 67826e2264 * path.cc (normalize_posix_path): Fix more slashdot madness. 2000-09-12 18:41:36 +00:00
Christopher Faylor 1d233ab53e * Makefile.in: Make clean target remove *.d. 2000-09-12 16:31:01 +00:00
Christopher Faylor 867df927a6 * path.cc (normalize_posix_path): Correctly deal with a "." parameter. 2000-09-11 17:21:13 +00:00
Christopher Faylor 9149d76e50 * cygheap.cc (init_cheap): Just use any old address for the cygwin heap.
* exceptions.cc (signal_exit): Don't terminate the main thread.  Just try to
exit in this thread really quickly.
* signal.cc (kill_pgrp): Fix typo which caused pinfo structure to be assigned
incorrectly.
2000-09-11 00:25:57 +00:00
Christopher Faylor 4f7ac76aae * dcrt0.cc (dll_crt0_1): Initialize thread and debug stuff before handling
exec/fork.
* dtable.cc (dtable::fixup_after_exec): Always clear out the read ahead buffer
whether closing or adjusting.
* path.cc (chdir): Avoid a compiler warning.
2000-09-10 16:43:47 +00:00
Christopher Faylor 4497c0df52 * path.cc (chdir): Use the full path for cwd_win32. Consider attempts to chdir
to strings of dots > 2 to be an error.  Pass 'dir' argument to cygcwd.set.
(cwdstuff::set): Need to treat arguments from chdir differently.
* path.h (cwdstuff): Add an argument to set.
2000-09-10 03:36:40 +00:00
Christopher Faylor 2137295d10 * lib/_cygwin_crt0_common.cc: Add missing header files. 2000-09-08 15:54:36 +00:00
Christopher Faylor 3b0d65eab9 * sigproc.h (sigframe::set): Eliminate second argument. Default bp to current
frame pointer rather than using this within the function, which is unstable
when this method is not inlined.
* net.cc: Eliminate use of second argument to sigframe.set throughout.
* select.cc (cygwin_select): Ditto.
* sigproc.cc (sig_send): Ditto.
2000-09-08 03:12:13 +00:00
Christopher Faylor f0338f545d Break out more header info into separate files. Use appropriate header files
throughout.
* shared.h: Remove.
* cygwin_version.h: New file.
* delqueue.h: New file.
* environ.h: New file.
* host_dependent.h: New file.
* perprocess.h: New file.
* registry.h: New file.
* security.h: New file.
2000-09-08 02:56:55 +00:00
Christopher Faylor 29ac7f89e3 Split out tty and shared_info stuff into their own headers and use throughout.
Include sys/termios.h for files which need it.
* tty.h: New file.
* shared_info.h: New file.
* fhandler.h: Move inline methods that rely on tty stuff to
fhandler_console.cc.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Set
output_done_event immediately after reading data to speed up tty output
processing.
(process_output): Set write_error to errno or zero.
(fhandler_tty_slave::write): Check previous write error prior to writing to
slave end of pipe.  This allows tty output to be slightly less synchronous.
* fhandler_console.cc (fhandler_console::tcsetpgrp): Moved here from
fhandler.h.
(fhandler_console::set_input_state): Ditto.
2000-09-07 16:23:51 +00:00
Christopher Faylor c1644acb23 * exceptions.cc (signal_exit): Reset all mutos owned by the main thread.
* fhandler.h: Define *_output_mutex macros for serializing tty output.
(fhandler_termios): Remove restart_output_event.  Define dummy output mutex
methods.
(fhandler_pty_master): Remove unneeded fixup_after_fork method.
* fhandler_termios.cc (fhandler_termios::line_edit): Acquire output_mutex when
CTRL-S is hit.  Release it on CTRL-Q.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Remove
inappropriate OutputStopped test here.  Just use the output mutex.
(fhandler_pty_master::fhandler_pty_master): Remove obsolete reference to
restart_output_event.
(fhandler_tty_common::close): Ditto.
(fhandler_pty_master::set_close_on_exec): Ditto.
(fhandler_pty_master::fixup_after_fork): Delete.
* tty.cc (tty::common_init): Ditto.
* sync.cc (muto::reset): New method.
* sync.h: Declare above method.
2000-09-07 01:18:37 +00:00
Christopher Faylor 8dec7b0379 * sigproc.cc: Add include file for proper definitions.
* spawn.cc: Ditto.
* winsup.h: Define cfree to avoid newlib pollution.
2000-09-06 21:03:10 +00:00
Christopher Faylor 3a71405fe2 * Makefile.in (CFLAGS): Ensure that -MD is always added even when CFLAGS is
overwritten.
2000-09-06 18:13:38 +00:00
Christopher Faylor b8a0fafe80 * path.cc (cwdstuff::get_initial): Keep caching alive.
(mount_info::conv_to_win32_path): Fill out relative path in failing case.
2000-09-06 06:42:08 +00:00
Christopher Faylor f7925ed552 Dummy file to accomodate programs which include
it unconditionally.
2000-09-06 02:21:44 +00:00
Christopher Faylor 3e0576957b * path.cc (normalize_posix_path): Deal with error return from cygcwd.get.
(normalize_win32_path): Ditto.
(mount_info::conv_to_win32_path): Ditto.
(cwdstuff::get): Set buf to NULL on error.
2000-09-06 01:56:17 +00:00
Christopher Faylor e321565bbc * path.cc (readlink): 'max' should be a 'min' or we'll suffer buffer overflow. 2000-09-05 21:51:06 +00:00
Christopher Faylor 7e24f1bf3a * path.cc (cwd_win32): Eliminate.
(cwd_posix): Eliminate.
(cwd_hash): Eliminate.
(cwdstuff::init): Rename from cwd_init.
(cwdstuff::fixup_after_exec): Rename from cwd_fixup_after_exec.
(cwdstuff::get): Rename from get_cwd_inner.
(normalize_posix_path): Eliminate cwd argument.  Just calculate when necessary.
(normalize_win32_path): Ditto.
(mount_info::conv_to_win32_path): Eliminate cwd retrieval here.
(mount_info::conv_to_posix_path): Ditto.
(hash_path_name): Accomodate additional methods in cwdstuff.
(get_cwd_win32): Eliminate.
(getcwd): Use cwdstuff methods.  Properly handle case where buf == NULL and len
< 0.
(cwdstuff::get_hash): New method.
(cwdstuff::get_initial): New method.
(cwdstuff::set): New method.
(cwdstuff::get): New method.
(cwdstuff::copy): New method.
* path.h: Move cwdstuff struct here.  Add a bunch of stuff to cwdstuff.  Make
cygcwd an extern.
* spawn.cc (spawn_guts): Use copy method to get copies of cwd info to pass to
execed process.
* dcrt0.cc (dll_crt0_1): Use cygcwd methods for cwd initialization.
2000-09-05 03:16:28 +00:00
Christopher Faylor f76325499a * path.cc (readlink): Check if buffer length is positive. Truncate output to
buffer length.  Don't terminate buffer with '\0'.
2000-09-04 17:52:42 +00:00
Christopher Faylor d8242040b8 * environ.cc (environ_init): Don't free the new environment table after we've
just copied stuff to it.
2000-09-03 04:45:52 +00:00
Christopher Faylor b0e82b74fb * Makefile.in: Add cygheap.o.
* child_info.h: Add specific exec class.
* cygheap.h: New file.  Contains declarations for cygwin heap.
* cygheap.cc: New file.  Implements cygwin heap functions.
* dcrt0.cc (quoted): Simplify due to new method for passing arguments between
cygwin programs.
(alloc_stack_hard_way): Attempt to handle overlapped stack.
(dll_crt0_1): Move child_info processing here.  Accomodate new method for
passing arguments between cygwin programs.  Initialize cygwin heap.  Establish
__argc and __argv variables.
(_dll_crt0): Move most of child_info processing to dll_crt0_1.
(cygwin_dll_init): Remove duplication.
* dtable.cc (dtable::extend): Allocate dtable using cygwin heap.
(dtable::build_fhandler): Ditto for fhandler type being constructed.
(dtable::dup_worker): Free new fhandler from cygwin heap on error.
(dtable::select_*): Don't assume that this == fdtab.
(dtable::linearize_fd_array): Delete.
(dtable::delinearize_fd_array): Delete.
(dtable::fixup_after_exec): New file.
(dtable::vfork_child_dup): Use cygwin heap.
(dtable::vfork_parent_restore): Ditto.
* dtable.h: Remove obsolete methods.  Add new method.
* environ.cc (posify): Eliminate already_posix parameter and logic.
(envsize): New function.
(_addenv): Use envsize.
(environ_init): Accept an argument pointing to an existing environment list.
If supplied, allocate space for this in the the program's heap.
* fhandler.cc (fhandler_base::operator =): Move here from fhandler.h.  Use
cygwin heap to allocate filenames.
(fhandler_base::set_name): Allocate/free names from cygwin heap.
(fhandler_base::linearize): Delete.
(fhandler_base::de_linearize): Delete.
(fhandler_base::operator delete): Free from cygwin heap.
(fhandler_base::~fhandler_base): Ditto.
* fhandler.h: Accomodate elimination of *linearize and other changes above.
* fhandler_console.cc (fhandler_console::fixup_after_exec): Rename from
de_linearize.
* heap.h: New file.
* fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Use cygwin heap for
name.  fhandler_tty::fixup_after_exec): Rename from de_linearize.
* fork.cc (fork): Call cygheap_fixup_in_child.
* heap.cc: Use declarations in heap.h.
* malloc.cc: Sprinkle assertions throughout to catch attempts to free/realloc
something from the cygwin heap.
* path.cc: Throughout, eliminate use of per-thread cache for cwd.  Use cwd_*
functions rather than cwd_* variables to access cwd_win32 and cwd_posix.
(cwd_win32): New function.
(cwd_posix): New function.
(cwd_hash): New function.
(cwd_fixup_after_exec): New function.
* path.h: Accomodate path.cc changes.
* pinfo.cc (pinfo_init): Accept a pointer to an environment table.  Pass this
to environ_init.  Eliminate old 'title' tests.
* pinfo.h: Accomodate above change in argument.
* spawn.cc (struct av): New method for building argv list.
(av::unshift): New method.
(spawn_guts): Allocate everything that the child process needs in the cygwin
heap and pass a pointer to this to the child.  Build argv list using new
method.  Eliminate delinearize stuff.
* thread.h: Eliminate _cwd_win32 and _cwd_posix buffers.
* winsup.h: Eliminate obsolete functions.  Add envsize() declaration.
2000-09-03 04:16:35 +00:00
Christopher Faylor 644eb6fe96 * Makefile.in: Remove "make check" support. It is now in winsup/Makefile.in. 2000-09-03 04:01:56 +00:00
Christopher Faylor 312a668a22 Remove everything 2000-09-03 03:42:01 +00:00
Christopher Faylor 05a7c4f7a9 Remove README 2000-09-03 03:41:19 +00:00
Christopher Faylor 7c5ef07168 remove everything and move it up a level. 2000-09-03 03:40:29 +00:00
Christopher Faylor 0ef7862533 * sigproc.cc (mychild): New function.
(proc_subproc): Use mychild() to determine if a specific pid is valid for
wait()ing.
2000-09-02 01:19:58 +00:00
Christopher Faylor 837528aa51 * sigproc.cc (sigproc_init): Create wait_sig_inited without auto-reset to avoid
potential races.
(init_child_info): Avoid unneeded test.
2000-09-01 21:04:34 +00:00
Christopher Faylor 488c7683e3 * sigproc.cc (proc_info): Rename proc_exists which takes a pid to "pid_exists".
* shared.h: Split out "child_info" stuff into a new header file and use where
necessary.  Declare pid_exists.
* child_info.h: New file.
2000-09-01 20:54:22 +00:00
Christopher Faylor 83a27d401a * errno.cc (set_errno_from_win_error): Actually use arguments to strace_printf. 2000-08-31 20:07:53 +00:00
DJ Delorie e873a0c7f3 * times.cc (gettimeofday): use GetSystemTimeAsFileTime to avoid a
conversion
(FACTOR): correct value
(genf): set milliseconds to zero, DOW to 4.
2000-08-30 22:37:24 +00:00
DJ Delorie 4f2aac14aa * grp.cc (getgroups): fail with EINVAL if array is not large
enough to hold all supplementary group IDs.
2000-08-29 18:59:26 +00:00
Christopher Faylor d824bcf985 * signal.cc (_raise): New function.
* exceptions.cc (unused_sig_wrapper): Remove _raise.
* sigproc.h (class sigframe): Default frames to skip to zero or suffer from
exuberant optimization.
* fhandler_tty.cc (fhandler_tty::write): Set appropriate errno when WriteFile
to pipe fails.
2000-08-29 02:06:49 +00:00
Christopher Faylor fde520bf6c * pinfo.h (pinfo): Un-inline release.
* pinfo.cc (pinfo::release): Move here from pinfo.h.
* sigproc.cc (proc_terminate): Remove bogus 'pinfo child' which caused strange
destruction of random regions of memory when destructor was invoked.
2000-08-26 03:48:37 +00:00
Christopher Faylor 3c2c374555 * dcrt0.cc (dll_crt0_1): Move set_os_type.
(_dll_crt0): To here.
(cygwin_dll_init): And here.
* external.cc (fillout_pinfo): Use more foolproof method for scanning for pids.
* pinfo.cc (set_myself): Eliminate myself_identity.init.
* sigproc.cc (wait_sig): Do it here instead to reduce the amount of time where
there could potentially be two processes with the same pid.
* spawn.cc (spawn_guts): Eliminate duplicate initialization.
* include/sys/cygwin.h: Mark unused PID_* elements.
2000-08-26 01:36:20 +00:00
Corinna Vinschen cd59f61488 * exec.cc (_execve): Change definition according to declaration in
newlib/libc/include/sys/unistd.h.
2000-08-25 19:52:04 +00:00
Christopher Faylor 239b06b864 * external.cc (cygwin_internal): Add CW_INIT_EXCEPTIONS to allow cygwin
exception handling on threads not created by cygwin.
* sigproc.cc (proc_terminate): Don't release pinfo structs since we are
exiting.
* include/sys/cygwin.h: Add CW_INIT_EXCEPTIONS.
2000-08-25 02:27:42 +00:00
Christopher Faylor de43b06d7b * ps.cc (main): Always print a cygwin process using cygwin paths. 2000-08-24 22:04:29 +00:00
Christopher Faylor a3cfd73ac9 * select.cc (cygwin_select): Correct logic for "always_ready" fds or when there
is no wait specified.
* syslog.cc (pass_handler::set_message): Zero the buffer prior to setting it.
2000-08-24 21:19:14 +00:00
Christopher Faylor be8924c43b Change attribution. 2000-08-24 19:07:29 +00:00
Christopher Faylor 78b8497ba3 * include/cygwin/core_dump.h: New file, contains structures used in cygwin core
core files.
* include/sys/procfs.h: New file, needed to autoconfigure cygwin core dumps
support in bfd.
2000-08-24 18:39:27 +00:00
Christopher Faylor 5a41f96dbb * environ.cc (parse_thing): nobinmode should force O_TEXT.
(regopt): Use correct path to find LOCAL_MACHINE registry options.
* fhandler.cc (fhandler_base::open): Set binary mode only when binmode ==
O_BINARY.
* pipe.cc (pipe): Pipe handling should rely on binmode not _fmode now that the
two are different.
2000-08-24 17:54:43 +00:00
Christopher Faylor 123469a0e9 * include/sys/cygwin.h (strace_printf_wrap): Force printing when
_STRACE_SYSTEM.
(strace_printf_wrap1): Ditto.
2000-08-24 17:23:35 +00:00
Christopher Faylor d1be315740 * debug.h: Allow some debug defines for use in header files. 2000-08-24 16:33:03 +00:00
Christopher Faylor f5589e4118 * dcrt0.cc (dll_crt0_1): Move exception list and constructor stuff earlier in
the process.  Use new second argument to set_myself.
(cygwin_dll_init): Initialize exception list and constructor stuff here.
(_dll_crt0): And here.  Also, deal with inherited pinfo shared memory region
from parent.
* pinfo.cc (set_myself): Accept a second argument signifying the a shared
memory region, passed from an execing parent.
(pinfo_init): Ditto.
* pinfo.h: Ditto.
* shared.h (child_info): Add a handle field to pass to child.
* spawn.cc (spawn_guts): Create a shared handle to pass to an execed child.
* winsup.h: Remove extraneous declaration.
2000-08-24 04:07:50 +00:00
Christopher Faylor e1cf4ae80c Revert previous erroneous checkin. 2000-08-23 14:56:28 +00:00
Christopher Faylor c19e7ba723 * include/sys/cygwin.h: Protect class definitions. 2000-08-23 14:53:25 +00:00
Christopher Faylor e136f5c0e0 * path.cc (symlink_info::check): Clear error on each iteration of extension
check.
2000-08-22 17:59:53 +00:00
Christopher Faylor 6d75cb08b3 * Makefile.in: Don't include '.d' file if there are none generated yet. 2000-08-22 15:25:25 +00:00
Christopher Faylor d6483e830f * include/sys/cygwin.h: Declare some thread classes.
* include/mntent.h: Avoid declaring functions.
2000-08-22 15:12:29 +00:00
Christopher Faylor bccd5e0d85 * winsup.h: Eliminate inclusion of most of the cygwin .h files. Use .h files
only in sources which require them.
* Makefile.in: Generate dependencies with -MD option.
2000-08-22 05:10:20 +00:00
Christopher Faylor 9e2baf8dfa * cygerrno.h: New file. Use this throughout whenever errno manipulation is
required.
* errno.cc: Use DWORD to hold Windows errors.
(geterrno_from_win_error): New function.
(seterrno_from_win_error): Use geterrno_from_win_error to convert supplied
windows error (suggested by Corinna Vinschen).
* path.cc (symlink_info): Add error element.
* path.cc (path_conv::check): Remove errno setting.  Use new symlink_info errno
element to set path_conv error, where appropriate.
(symlink_info::check): Set error element rather than attempting to manipulate
errno.  Add more checks for trailing / and /..  even though they are currently
useless.  Avoid setting EINVAL.
* path.cc (normalize_posix_path): Correct check for trailing /.
2000-08-22 03:58:47 +00:00
Christopher Faylor 6b85369f82 Update copyright. 2000-08-21 18:27:38 +00:00
DJ Delorie d3bff3131f * include/cygwin/cygwin_dll.h (DECLARE_CYGWIN_DLL): hinstance,
not handle. (reverse of previous diff)
2000-08-21 18:15:50 +00:00
DJ Delorie 20ffb3ee16 * include/cygwin/cygwin_dll.h (DECLARE_CYGWIN_DLL): handle,
not hinstance.
2000-08-21 17:47:52 +00:00
Christopher Faylor 6052f47178 * Makefile.in: hinfo.o -> dtable.o. 2000-08-18 20:01:04 +00:00
Christopher Faylor dc999f678d hinfo -> dtable 2000-08-18 19:51:02 +00:00
Corinna Vinschen 83eda97dff * dtable.cc (dtable::dup2): Extend fdtab if newfd is out of current
allocated bounds.
2000-08-18 18:14:08 +00:00
Christopher Faylor e48a8ed6ec * mkvers.sh: Properly trap exit removal of temp file. Remove debugging
statement.
2000-08-12 05:48:51 +00:00
Christopher Faylor 84cf3d22e3 Correct order in include files. 2000-08-12 05:47:12 +00:00
Christopher Faylor b2007749a8 * poll.cc: Make winsup.h the first include file, re 2000-08-02 change. 2000-08-12 05:39:41 +00:00
Christopher Faylor e2ebe11776 * winsup.h: Split out dtable definitions into separate header file.
* dtable.h: New file.
* sigproc.h: Eliminate pinfo.h usage here.  Use it in source files that need
it.
2000-08-12 05:35:42 +00:00
Christopher Faylor 3ee92b51d6 * Makefile.in: Use dtable.o rather than hinfo.o. 2000-08-12 05:09:27 +00:00
Christopher Faylor 9015e0fb8c Rename hinfo -> dtable. Name the former dtable array 'fdtab'. 2000-08-12 04:48:44 +00:00
Corinna Vinschen 427b6d036e * poll.cc: Allow any descriptor and any number of descriptors.
Allocate fd_set struct sdynamically.
2000-08-11 20:34:24 +00:00
Christopher Faylor bbda7ca078 Fix premature use of fdtab. 2000-08-11 13:49:42 +00:00
Corinna Vinschen e82d75cc2b * poll.cc: Add bounds checking for file descriptors. Return POLLNVAL
if fd is invalid. Return POLLERR for each valid fd if cygwin_select
        returned with error.
        include/sys/poll.h: Change POLLERR comment according to above change.
2000-08-11 12:51:47 +00:00
Christopher Faylor 7b972f5da5 * syslog.cc (syslog): Use a less malloc-intensive method for allocating the
buffer.  Also fix a buffer overrun.
2000-08-11 01:56:05 +00:00
Christopher Faylor b5ae313ab5 * winsup.h: Change strchr inline for strange gcc problem.
* select.cc (select_stuff::wait): Bounds check w4 array.
2000-08-10 19:33:54 +00:00
Christopher Faylor b58f5598cb * dir.cc (readdir): Ensure that errno is *only* set when we've run out of
filenames.
* fhandler.cc (fhandler_disk_file::fstat): Use modern method for saving errno,
making it effective for the whole function.
2000-08-10 19:20:11 +00:00
Christopher Faylor 0072fdab86 * select.cc (allocfd_set): Zero allocated fd_set.
(cygwin_select): Move fd_set copying logic from ::wait to here.  Use common
return through sell.poll.
(select_stuff::wait): Just return success or failure and let caller fill in
fd_set.
* pinfo.h (pinfo): Eliminate self-referential pointer to sidbuf since pinfo
structure exists at random locations now.
* fork.cc (fork): Use 'use_psid' element to control when the psid is relevant.
* shared.cc (sec_user): Ditto.
* spawn.cc (spawn_guts): Ditto.
* uinfo.cc (internal_getlogin): Ditto.
* syscall.cc (seteuid): Ditto.  Set use_psid element.
2000-08-09 02:33:47 +00:00
DJ Delorie c51a2a8ba4 * fhandler_serial.cc (tcsendbreak): "sleeptime" argument to usleep()
must be in units of microseconds, not milliseconds.
2000-08-08 20:46:47 +00:00
Christopher Faylor 709262970f * include/cygwin/cygwin_dll.h: Remove extraneous (and incorrect) declarations. 2000-08-07 04:13:34 +00:00
Christopher Faylor 91892f50d9 * hinfo.cc (hinfo::find_unused_handle): Just check for table entry == NULL
since we are already bounds checked by default.
* thread.cc (ResourceLocks::Lock): Streamline this function since it is called
a lot.
(ReleaseResourceLock): Ditto.
2000-08-04 04:04:46 +00:00
Christopher Faylor e5dd88116a * select.cc (fhandler_console::select_read): Call set_cursor_maybe since select
may block and cursor may not be visible.
* select.cc (fhandler_console::select_write): Ditto.
* select.cc (fhandler_console::select_except): Ditto.
2000-08-04 01:33:33 +00:00
Christopher Faylor 14323f6a97 * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Set length field
correctly when "need_nl".
2000-08-03 13:02:09 +00:00
Christopher Faylor 47026c0785 * fork.cc (vfork): Store complete stack frame in vfork_save structure for later
recovery.
* spawn.cc (spawn_guts): Reorganize slightly to consolidate handling when there
is a CreateProcess error.
(_spawnve): Only longjmp back to vfork handling when a process has been
successfuly started.
* winsup.h (vfork_save): Extend to include frame info.  Remove obsolete cpplus
conditionals.
2000-08-03 03:02:41 +00:00
DJ Delorie 9ccb71b88f add winsup.h 2000-08-02 20:13:18 +00:00
Christopher Faylor 20d7f75837 * strace.cc (strace::prntf): Make second argument the function name, rather
than use special format options.
(strace::vprntf): Ditto.
(getfunc): New function.
* include/sys/strace.h: Reflect above changes.
* smallprint.c (__small_vsprintf): Eliminate '%F' formatting.
* pinfo.cc (set_myself): Modify for new strace::prntf parameter.
* errno.cc (seterrno_from_win_error): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__release_output_mutex): Ditto.
2000-08-02 19:26:01 +00:00
Christopher Faylor c1efa78572 * regexp/regexp.c: Add winsup.h. 2000-08-02 17:21:27 +00:00
DJ Delorie 4c8d72ded5 * winsup.h: take out protections of environ, errno, allow C use
* *.cc: put winsup.h before other headers (for __INSIDE_CYGWIN__);
use cur_environ() instead of just environ
* times.cc: remove import protections
* glob.c: add winsup.h
* localtime.c: ditto
* smallprint.c: ditto
* Makefile.in: don't __INSIDE_CYGWIN__ as it messes up profiling.
2000-08-02 16:28:18 +00:00
Christopher Faylor ad8dea13f0 * include/sys/strace.h: Fix strace definition. 2000-08-02 15:24:45 +00:00
Christopher Faylor a5a965ff62 * strace.h: Add kludgy workarounds to avoid using deprecated methods for
variable argument macros when possible.
* sigproc.cc: Throughout, use sigproc_printf rather than sip_printf.
* strace.cc (strace::prntf): Remove 'active' check, since callers are supposed
to ensure this.
(__system_printf): Remove.  Subsumed by strace::prntf.
* winsup.h: Define "NEW_MACRO_VARARGS" to indicate when to use new macro
varargs capability.
2000-08-02 03:42:31 +00:00
Christopher Faylor a9867e1b58 * fhandler_console.cc: Remove VK_DIVIDE detection.
(get_nonascii_key): Simplify previous patch to return ascii char if it is
non-zero.  Add a second "temporary buffer" argument to help with thread safety.
* select.cc (peek_console): Pass a temporary buffer argument to
get_nonascii_key.
2000-07-30 17:58:48 +00:00
Christopher Faylor 751669bbb0 * fhandler_console.cc: Add VK_DIVIDE detection. Return virtual keycode if it
is not detected and it is less than ' '.
2000-07-29 19:07:15 +00:00
Christopher Faylor af5153a036 * path.cc (chdir): Avoid trailing dot calculation when chdir == '/' or we end
up with an empty string.
2000-07-29 17:36:05 +00:00
Christopher Faylor 84c7d40932 * include/cygwin/version.h: Bump DLL minor version number to 5 due to all of
the changes below.  Redefine process structure to avoid a fixed size table.
Redefine pinfo/_pinfo classes.  Use these throughout.
* dcrt0.cc (dll_crt0_1): Accomodate set_myself argument change.
(__api_fatal): Accomodate _pinfo::record_death argument change.
* exceptions.cc (really_exit): Ditto.
(sig_handle_tty_stop): Use pinfo constructor to access process info.
(events_init): Don't create pinfo_mutex since it is no longer required.
* external.cc (fillout_pinfo): Use winpids class to iterate over all system
pids.
(cygwin_internal): lock_pinfo_for_update and unlock_pinfo are now noops.
* fhandler_termios.cc (fhandler_termios::set_ctty): Use pinfo constructor to
access process info.
* fork.cc (fork): Reorganize to initialize child info after the child has
started since that is when we know the child's winpid, which is necessary to
allocate the pinfo shared memory.
* mmap.cc (recreate_mmaps_after_fork): Change arg type to _pinfo.
* pinfo.cc: Rename pinfo methods to _pinfo throughout.  Eliminate pinfo_list
stuff.
(set_myself): Accept a pid argument now.  Call pinfo initializer to initialize
myself.  Detect when this is an "execed" process and create an "indirect" pid
block.
(pinfo_init): Accomodate set_myself arg change.
(procinfo): Remove.
(pinfo::lock_pinfo): Remove.
(pinfo::unlock_pinfo): Remove.
(pinfo::init): New method.  Allocates shared memory space for process pinfo
structure.
(pinfo::record_death): Don't call locking functions.
(cygwin_winpid_to_pid): Simplify by using new pinfo constructor.
(EnumProcessesW95): New function for iterating over processes on Windows 95.
(winpids::winpids): New constructor for winpids class.  Sets up a list of
process ids.
(enum_init): Initialize w95/wnt pid enumerators.
* shared.cc (shared-info::initialize): Remove pid initialization.
* shared.h: Move pinfo stuff into pinfo.h.
(class shared_info): Remove pinfo_list element.
* signal.cc (kill_worker): Use pinfo constructor to access process info.
(kill_pgrp): Ditto.  Use winpids methods to access list of processes.
* sigproc.cc: Throughout, modify to use _pinfo where appropriate.
(proc_exists (pid_t)): New function.  Determines if a process exists based on
the pid.
(proc_exists (_pinfo *p): Use new proc_exists function above.
(proc_subproc): Copy pinfo stuff around rather than _pinfo pointers.  Try to be
careful about releasing shared memory when we don't need it anymore.  Remove
pinfo locks.
(remove_zombies): Remove pinfo memory when zombie is going away.
* sigproc.h: Reflect _pinfo/pinfo changes in sigproc.cc.
* spawn.cc (spawn_guts): Eliminate pinfo *child argument.  Reorganize to only
initialize child pinfo after process has been started and we know the windows
pid.
(_spawnve): Reflect spawn_guts changes.
* syscalls.cc (setpgid): Use pinfo constructor to access process info.
(getpgid): Ditto.
(internal_getlogin): Use _pinfo.
* winsup.h: Eliminate pinfo_mutex.  Eliminate spawn_guts declaration since it
is static now.  Reflect set_myself argument change.
* include/sys/cygwin.h: Add some PID_* enums to accomodate new pinfo stuff.
* include/cygwin/version.h: Update minor version for cygdrive changes below.
2000-07-29 16:24:59 +00:00
Christopher Faylor 53211514a0 * environ.cc (parse_thing): Make binmode a DWORD.
* hinfo.cc (hinfo::init_std_file_from_handle): Use 'binmode' to determine
default open mode.
* winsup.h: Declare binmode.
2000-07-29 16:01:23 +00:00
Christopher Faylor 9eef1530d5 * include/cygwin/cygwin_dll.h: Update for modern compilers.
* lib/cygwin_crt0.c: Inexplicably need to define alloca for newer compilers.
* fhandler.h (fhandler_console): Add new method.
* fhandler.cc (fhandler_console::set_cursor_maybe): New method.
(fhandler_console::read): Set cursor if it has moved to make it visible.
2000-07-29 04:19:24 +00:00
Christopher Faylor d1baac7725 Minor formatting change. 2000-07-28 23:21:04 +00:00
Christopher Faylor 637f5ce0fe * dcrt0.cc (dummy_autoload): Add load statement for RegDeleteValueA.
* external.cc (get_cygdrive_prefixes): New function.
(cygwin_internal): Add CW_GET_CYGDRIVE_PREFIXES case.
* path.cc (mount_info::read_cygdrive_info_from_registry): Read system cygdrive
prefix if user one is undefined.
(mount_info::write_cygdrive_info_to_registry): Write cygdrive prefix to the
appropriate registry hive.  Overwrite in-memory copy of cygdrive, if
appropriate.
(mount_info::remove_cygdrive_info_from_registry): New method.
(mount_info::get_cygdrive_prefixes): New method.
(cygwin_umount): Remove cygdrive prefix, if appropriate.
* registry.cc (reg_key::killvalue): New method.
* shared.h (class reg_key): Add killvalue, remove_cygdrive_info_to_registry,
and get_cygdrive_prefixes declarations.
* include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GET_CYGDRIVE_PREFIXES.
2000-07-28 22:33:43 +00:00
Christopher Faylor 403a661709 * include/cygwin/version.h: Bump DLL minor version number to 4. 2000-07-28 03:35:52 +00:00
DJ Delorie d0b178fe3a * testsuite/winsup.api/winsup.exp: ignore stdout by default
* testsuite/winsup.api/crlf.c: non-verbose by default

* winsup.h: prune out windows headers we don't normally need
* assert.cc: add wingdi.h and winuser.h
* fhandler_console.cc: ditto
* fhandler_windows.cc: ditto
* select.cc: ditto
* spawn.cc: ditto
* strace.cc: ditto
* tty.cc: ditto
* window.cc: ditto
* hinfo.cc: add winsock.h
* syscalls.cc: add winnls.h
* uinfo.cc: ditto

* include/windows.h: optimize non-inclusion of repeat headers
2000-07-27 17:30:51 +00:00
Christopher Faylor 6864e5d7b4 * fhandler.cc (fhandler_disk_file::fstat): Allow block calculation to succeed
for files >= 2GB and <= 4GB.
2000-07-27 14:26:03 +00:00
Christopher Faylor 020a861340 fix typo. 2000-07-27 03:05:38 +00:00
Christopher Faylor e06f58136b Give signal_exit noreturn attribute. 2000-07-26 20:36:19 +00:00
Christopher Faylor 866c04e9cf * exceptions.cc (signal_exit): Renamed from "really+exit". Always sets
EXIT_SIGNAL bit and reorganizes exit value for backwards cygwin handling.
(handle_exceptions): Call signal_exit.  Set "core dumped" bit.
(sig_handle): Call signal_exit.  Set "core dumped" bit appropriately.
2000-07-26 20:13:27 +00:00
Corinna Vinschen 0d4c5950ff * environ.cc (posify): Revert previous patch.
(_addenv): Remove check_null_empty_path from here.
        (putenv): Call check_nullempty_path.
        (setenv): Call check_nullempty_path for name as well here.
        Don't report an error if value is empty string.
        (environ_init): Revert usage of newp.
2000-07-26 18:51:14 +00:00
Christopher Faylor f489e86b8f * syscalls.cc (stat_worker): Make stat return correct st_blocks for files with
size bigger than 2Gb and less than 4Gb
2000-07-26 17:48:49 +00:00
Corinna Vinschen a246b47b67 * security.cc (lookup_name): Search on local machine first if
myself->domain is not empty.
2000-07-26 15:44:58 +00:00
Christopher Faylor 6e76b010c3 * fhandler_console.cc (fhandler_console::read): Explicitly set cursor to make
it visible while waiting in WaitForMultipleObjects.
2000-07-26 13:59:23 +00:00
Christopher Faylor f653e4ddc1 Add missing ChangeLog entry. 2000-07-26 13:42:01 +00:00
Corinna Vinschen 1d8fc847ee * passwd.cc: Change name of passwd_in_memory_p to passwd_state.
Change type to enum. Change storage class to static. Adjust comments.
        (read_etc_passwd): Set passwd_state to different values when loaded
        from file in contrast to being emulated.
        (search_for): Return default passwd entry if passwd is emulated or
        it's a request for the current user. Otherwise return NULL.
2000-07-26 11:48:38 +00:00
Christopher Faylor 00edcbb0cb * syscalls.cc (statfs): Use path_conv method to convert input path. 2000-07-26 01:56:48 +00:00
Christopher Faylor 2a1a9785eb * syscalls.cc (_link): Avoid extraneous call to cygwin_conv_to_win32_path. 2000-07-26 01:44:16 +00:00
Corinna Vinschen 8b6ebe8fd5 * syscalls.cc (_link): Corrected previous patch. 2000-07-24 19:14:38 +00:00
Corinna Vinschen 9602ffc30b * fhandler.h (class fhandler_dev_random): Add members for managing
pseudo randomness.
        * fhandler_random.cc: Rearrange. Use pseudo random number generator
        as entropy source if system entropy isn't available and if device is
        used as /dev/urandom. Allow initializing device by calling write().
2000-07-24 11:33:02 +00:00
Corinna Vinschen bb7f93f898 * fhandler.h: Add comment. 2000-07-23 21:13:05 +00:00
Corinna Vinschen c49b9c439c * fhandler.h (class fhandler_dev_raw): Add private member `varblkop'
to be set when variable blocksize mode is on.
        * fhandler_raw.cc: Eliminate `\n' from trace output.
        (clear): Set `varblkop' to 0.
        (dup): Copy varblkop as well.
        (writebuf): Care for variable blocksize.
        (open): Ditto.
        (raw_read): Ditto.
        (raw_write): Ditto.
        * fhandler_tape.cc (open): Ditto.
        (ioctl): Ditto. Some cleanups.
2000-07-23 19:33:44 +00:00
Corinna Vinschen 9fb628fc57 Patch suggested by Kazuhiro Fujieda <fujieda@jaist.ac.jp>.
* winsup.h: Add new macros sys_wcstombs and sys_mbstowcs.
        * syscalls.cc (_link): Replace calls to mbstowcs by call to
        sys_mbstowcs.
        * uinfo.cc (internal_getlogin): Replace calls to wcstombs and
        mbstowcs by calls to sys_wcstombs and sys_mbstowcs. Replace
        usage of constants by meaningful defines. Use result of
        GetSystemDirectory for HOMEPATH and HOMEDRIVE as a last resort.
2000-07-22 16:43:54 +00:00
Corinna Vinschen ede1fee4ca * spawn.cc (span_guts): Retrieve security attributes before setting
psid to NULL.
2000-07-21 19:34:35 +00:00
Corinna Vinschen 6780333e20 * security.cc (acl_worker): Use stat_suffixes in call to path_conv
just as in `stat_worker'.
2000-07-21 10:06:13 +00:00
Corinna Vinschen c4b881eb44 * spawn.cc (spawn_guts): Don't restore impersonation in case
of _P_OVERLAY. Clean up slightly. Accomodate comments.
2000-07-19 20:27:27 +00:00
Corinna Vinschen a67f4165ae * shared.h (class pinfo): New members `root' and `rootlen'.
* syscalls.cc (chroot): Set new root for process.
        * path.cc (getcwd_inner): Add parameter to force use of
        new root from chroot() call.
        (ischrootpath): New macro.
        (normalize_posix_path): Care for changed root dir.
        (normalize_win32_path): Ditto.
        (getcwd_inner): Ditto.
        (chdir): Eliminate trailing path component consisting
        entirely of dots.
        * fork.cc (fork): Copy pinfo members regarding chroot().
        * spawn.cc (_spawnve): Ditto.
        * dir.cc (opendir): Don't use computed win32 path if
        chroot() took place.
2000-07-19 20:14:24 +00:00
Christopher Faylor 45b5257519 Update copyright info. 2000-07-19 17:42:16 +00:00
Christopher Faylor 49a1613414 * dll_init.cc (dll_list::alloc): Fix debugging output. 2000-07-18 02:26:46 +00:00
Christopher Faylor b7be354a26 Update ChangeLog. 2000-07-18 00:12:10 +00:00
Christopher Faylor 5bc584ba65 Throughout, eliminate third argument to path_conv and use new PC_* constants
for second argument.
* path.h: Generalize SYMLINK_* constants to PC_*.
(path_conv): Create a new method.  Fold third argument into second.
* dll_init.cc (dll_list::alloc): Try harder to find space to allocate dll
struct.
(dll_dllcrt0): Don't check sanity if we've already called dll_crt0.
* path.cc (path_conv::check): Don't check for a null or empty path unless
specifically told with a flag setting.
(check_null_empty_path): New function, adapted from macro.
* syscalls.cc (_rename): Use already-determined file attributes rather than
checking again.
* lib/cygwin/cygwin_attach.dll.c (cygwin_attach_dll): Use a static per_process
structure since this is apparently supposed to be zeroed.
* lib/cygwin_crt0.c (cygwin_crt0): Zero per_process structure sent to older
DLLs.
2000-07-17 19:18:21 +00:00
Corinna Vinschen 17811f7bbe Patch suggested by Eric Fifer <EFifer@sanwaint.com>
* poll.cc (poll): Fix erroneous negations.
2000-07-17 17:42:00 +00:00
Corinna Vinschen b0d5cd02dc * environ.cc (setenv): Use __cygwin_environ instead of
environ after reallocating environment space.
2000-07-17 15:59:27 +00:00
Christopher Faylor c609f9dcec * _cygwin_crt0_common.cc: Undef 'environ' or suffer compiler error. 2000-07-17 00:24:56 +00:00
Christopher Faylor 0763ee9d83 * environ.cc: Use new definition of "environ" throughout.
(environ_init): Explicitly initialize __cygwin_environ.
(cur_environ): New function.  Detects when user has updated their environment.
* exec.cc: Use 'environ' define throughout rather than __cygwin_environ.
* spawn.cc: Ditto.
* winsup.h: Declare cur_environ, main_environ, environ.
2000-07-16 20:06:11 +00:00
Christopher Faylor b4e59f5f14 * acconfig.h: Add support for NEWVFORK.
* config.h.in: Ditto.
* configure.in: Add --enable-vfork option.
* configure: Regenerate.
* dcrt0.cc (quoted): Detect and fix up quoted backslashes.
* sigproc.cc (proc_subproc): Correctly name handle of newly added child process
to avoid erroneous debugging messages about closing the wrong handle.
2000-07-16 17:38:41 +00:00
Christopher Faylor 8e382d8049 * spawn.cc (spawn_guts): Use \ for quoting '"'.
* dcrt0.cc (quoted): Understand \ quoting for '"'.
2000-07-16 06:31:06 +00:00
Christopher Faylor 2768430b64 Slightly more efficient version of previous change. 2000-07-16 04:37:43 +00:00
Christopher Faylor 01e6597b1c * dcrt0.cc (build_argv): Strip quotes from argv[0] since it should never be
globified.
2000-07-16 04:34:05 +00:00
Christopher Faylor c77c441991 Update comments. 2000-07-16 04:10:33 +00:00
Christopher Faylor 92e30b7535 * dll_init.cc (dll_list::alloc): Round correctly. Use VirtualAlloc since
shared file mapping is unnecessary.
(dll_list::detach): Release memory via VirtualFree since there we no longer use
shared file mapping.
2000-07-15 04:36:10 +00:00
Christopher Faylor 2eb392bd77 * hinfo.cc (hinfo::linearize_fd_array): Make max_used_fd an int so that we can
detect when there are no fds to pass.
* dcrt0.cc (host_dependent_constants::init): Revert Sat Mar 18 01:32:04 2000
change.
(dll_crt0_1): Set "cygwin_finished_initializing" flag.
(dll_crt0): Don't perform memcpy if uptr is already set to internal structure.
(_dll_crt0): Remember location of programs envptr.
* dll_init.h (per_module, dll, dll_list): Revamp.
* dll_init.cc: Revamp.  Use new classes.
* fork.cc (fork): Use new revamped dll, dll_list, and per_module stuff.
* environ.cc: Use __cygwin_environ throughout rather than the
user_data->envptr.
* exec.cc: Ditto.
* spawn.cc: Ditto.
* winsup.h: Declare update_envptrs, cygwin_finished_initializing.
* lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Revert previous change.
* lib/cygwin_attach_dll.cc (cygwin_attach_dll): Always pass in own per_process
structure or we end up overwriting information from the main program.
2000-07-15 02:48:11 +00:00
Christopher Faylor 5f9316981a * debug.cc (thread_stub): Use impure_ptr in place of reent_data.
* dll_init.cc (dll_dllcrt0): Replace erroneous use of local symbol with correct
__cygwin_user_data->impure_ptr.
2000-07-12 04:49:07 +00:00
Christopher Faylor a0f7b496ad * lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Don't reset environ if
already set.
2000-07-12 04:02:45 +00:00
Christopher Faylor 69859e8697 * fhandler_console.cc (fhandler_console::read): Unicode interface to
ReadConsoleInput only exists on W2K, so use workaround from Kazuhiro Fujieda
<fujieda@jaist.ac.jp>.
2000-07-10 23:08:45 +00:00
Christopher Faylor 5814b26cc7 Add missing text. 2000-07-10 15:31:46 +00:00
Christopher Faylor 356d1c6ab0 * Makefile.in (install): Install textmode.o as well as binmode.o. 2000-07-10 15:30:04 +00:00
Corinna Vinschen d501c6adee * spawn.cc (spawn_guts): Close handle `hToken' only if it's not
copied from myself->token.
        * syscalls.cc (seteuid): Replace CopySid by memcpy which is foolproof
        here.
2000-07-09 21:02:44 +00:00
Christopher Faylor 5fc3f2d40a Slight optimization. 2000-07-09 16:21:55 +00:00
Christopher Faylor bd4ec49671 * cygwin.din: Export _getmode and getmode to allow querying of binary state of
an fd.
* external.cc (cygwin_internal): Add handling of perfile_table setting.
* fhandler.cc (perfile_table): New global.
(fhandler_base::get_default_fmode): New method to return a file's default mode
based on its name.
(fhandler_base::open): Use get_default_mode method to determine a file's mode.
Record file mode in file flags.
* fhandler.h (fhandler_base): Declare get_default_fmode
* syscalls.cc (getmode): New function.
* sys/cygwin.h (__cygwin_perfile): New structure.
(cygwin_getinfo_types): Move outside of WINVER conditional.
(per_process): Move inside of WINVER conditional.
2000-07-09 05:29:51 +00:00
Christopher Faylor 85219b356e * external.cc (cygwin_internal): Export __cygwin_user_data.
* include/sys/cygwin.h: Allow definition of per_process even when not compiling
with C++.
(cygwin_getinfo_types): Add CW_USER_DATA.
* lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Get __cygwin_user_data
pointer from cygwin_internal.  If it doesn't exist, return failure.  Use either
this pointer or passed in pointer throughout.  Clear forkee.
* lib/crt0.h: Accomodate argument changes to _cygwin_crt0_common.
* lib/cygwin_attach_dll.c (cygwin_attach_dll): Reorganize to allow use of newer
binaries with older DLLs.  Detect older DLLs when _cygwin_crt0_common returns 0
and allocate space for a per_process structure on the stack.
* lib/cygwin_crt0.c (cygwin_crt0): Ditto.
2000-07-08 04:36:27 +00:00
Corinna Vinschen 52cec10c67 * include/sys/cygwin.h: Hide internal data types in per_process
when not __INSIDE_CYGWIN__.
2000-07-07 08:35:31 +00:00
Christopher Faylor 737a86d32f * dcrt0.cc (__cygwin_user_data): Initialize.
(dll_crt0_1): Eliminate user_data initialization.
(dll_crt0): Set up impure_ptr_ptr for older executables.
(cygwin_dll_init): Eliminate user_data initializations.
(__api_fatal): Don't check for user_data initialization.
* dll_init.cc (struct dll): Store entire contents of per_process rather than
just a pointer.
(add): Ditto.
(initOneDll): Don't check for user_data initialization.
(DllList::recordDll): Store contents of per_process argument.
(DllList::detachDll): Pass address of per_process field.
(DllList::initAll): Ditto.
(DllList::doGlobalDestructorsOfDlls): Ditto.
(DllListIterator::operator *): Ditto.
(dll_dllcrt0): Default to __cygwin_user_data if arg is NULL.
* include/sys/cygwin.h: Reorganize per_process to eliminate obsolete fields and
accomodate new way of initializing.
* lib/_cygwin_crt0_common: Initialize _impure_ptr from
__cygwin_user_data.impure_ptr.
2000-07-05 23:46:44 +00:00
Christopher Faylor 1d613351e5 * exceptions.cc (try_to_debug): Prevent recursive spawning of JIT debugger.
Treat special event from debugger as command to continue.
2000-07-04 19:07:35 +00:00
Corinna Vinschen 0106a9b755 * poll.cc (poll): Zero out `open_fds' as well. 2000-07-04 17:36:44 +00:00
Corinna Vinschen 914e40dfe6 * include/cygwin/version.h: Bump API minor version to 24. 2000-07-04 17:25:11 +00:00
Corinna Vinschen 1ec2e52134 * security.cc (read_sd): Eliminate OemToChar. 2000-07-04 17:03:52 +00:00
Corinna Vinschen afb7e7196a * poll.cc: New file. Implement `poll' system call.
* include/poll.h: Ditto.
        * include/sys/poll.h: Ditto.
        * Makefile.in: Add poll.o as dependency.
        * cygwin.din: Add poll and _poll symbols.
2000-07-04 16:58:49 +00:00
Christopher Faylor 610739191f * dcrt0.cc (dll_crt0_1): Eliminate SetFileApisToOEM and CharToOem.
* (dummy_autoload): Add functions used in fhandler_console.
* fhandler_console.cc (fhandler_console::read): Use ENCHANCED_KEY flag to
distinguish extended keys.  Translate an input character from the OEM code page
to the ANSI code page.
* (fhandler_console::write_normal): Translate output characters from the ANSI
code page to the OEM code page.
* syscalls.cc (_link): Use MultiByteToWideChar instead of OemToCharW.
2000-07-04 02:26:20 +00:00
Christopher Faylor 3b09c754da Revert errnoneous commit. 2000-07-03 20:16:23 +00:00
Christopher Faylor 8366e93be9 * exceptions.cc (stack_info::walk): Use method to find offset.
(handle_exceptions): Be more assertive in finding ebp for use under W2K.
Create a dummy stack frame for cases where program is dying and a stack dump is
being output.
(sig_handle): Fill out a GetThreadContext for use with a user-generated "core
dump".
2000-07-03 20:14:06 +00:00
Corinna Vinschen 4bedf498d6 * include/cygwin/socket.h: Remove SOCK_PACKET define since it's
not supported by Windows sockets.
2000-07-03 09:23:11 +00:00
Christopher Faylor b6cdb2c349 * dcrt0.cc (user32_init): Add primitive guard against concurrent attempts to
call this function.  Also add temporary debugging code to display a message if
the function is called multiple times.
(api32_init): Ditto.
2000-07-03 01:55:17 +00:00
Corinna Vinschen c8c609ff0a Replaced buggy ChangeLog entry 2000-07-02 16:42:15 +00:00
Corinna Vinschen 0c4d2abd99 * winsup.h: Define MAX_SID_LEN and new MAX_HOST_NAME.
* fork.cc (fork): Use above defines instead of numerical constants.
        * shared.cc (sec_user): Ditto.
        * shared.h (class pinfo): Ditto.
        * syscall.cc (seteuid): Ditto.
        * spawn.cc (_spawnve): Ditto. Eliminate conditional.
        (spawn_guts): Set child->uid = USHRT_MAX when user context will be
        changed in child process.
        * uinfo.cc (uinfo_init): Check for myself->uid instead of myself->psid
        to avoid reloading of /etc/passwd on process startup if ntsec is off.
        Use above defines instead of numerical constants.
        * security.cc: Move define for MAX_SID_LEN to winsup.h.
2000-07-02 10:17:44 +00:00
Christopher Faylor c570d680fb Add some comments. 2000-07-02 02:03:50 +00:00
Corinna Vinschen 760d376e34 * uinfo.cc (uinfo_init): Eliminate calls to read_etc_group()
and read_etc_passwd().
2000-07-02 00:00:17 +00:00
Corinna Vinschen ebbd4e8fb3 Changes by Kazuhiro Fujieda <fujieda@jaist.ac.jp>
* assert.cc (__assert): Reduce dependency on newlib.
        * exec.cc: Eliminate unnecessary inclusion of ctype.h.
        * glob.c: Ditto.
        * hinfo.cc: Ditto.
        * init.cc: Ditto.
        * strace.cc: Ditto.
        * tty.cc: Ditto.
        * grp.cc (parse_grp): Eliminate atoi.
        * passwd.cc (grab_int): Ditto.
        * grp.cc (getgroups): Eliminate str{n,}casecmp.
        * path.cc (get_raw_device_number): Ditto.
        * path.cc (sort_by_native_name): Ditto.
        * spawn.cc (iscmd): Ditto.
        * uinfo.cc (internal_getlogin): Ditto.
2000-07-01 17:30:35 +00:00
Christopher Faylor 51b2ec5d03 * binmode.c (cygwin_premain0): Fix erroneous clearing of bit.
* textmode.c (cygwin_premain0): Ditto.
2000-07-01 15:45:20 +00:00
Christopher Faylor 44cac41121 Remove asm labelling from _dll_crt0 since it seems to confuse different versions
of gcc differently.
2000-07-01 04:40:20 +00:00
Christopher Faylor 72f8054fad * dcrt0.cc (_dll_crt0): Renamed from dll_crt0 ().
* winsup.h: Accomodate above change.
* cygwin.din: Ditto.
* lib/cygwin_crt0.c: Ditto.
2000-07-01 04:26:45 +00:00
Christopher Faylor e337fd40cb Forgot perthread.h. 2000-07-01 03:52:33 +00:00
Christopher Faylor 14a3bc2fa1 * Makefile.in: Use variables rather than configure constructs where
appropriate.
(LIBCOS): Find additional stub library stuff in their own subdirectory.
* dcrt0.cc: Convert user_data pointer to static __cygwin_user_data area.
(do_global_ctors): Check magic_bisquit for initialization.
(dll_crt0_1): First group of premain functions prior to fd initialization.  Run
second group before calling main.
(dll_crt0 ()): New function, called from new initialization code.
(dll_crt0 (per_process *uptr)): Call new dll_crt0 () function on
initialization.
* debug.cc (thread_stub): Initialize bottom of stack with per-thread info.
* environ.cc (parse_thing): Use binmode global to control CYGWIN=binmode
behavior.
* fhandler.cc (fhandler_base::open): Allow explicit setting of __fmode to
O_BINARY or O_TEXT to override disk mount settings.
* libcmain.cc: Move to lib subdirectory.
* libccrt0.cc: Ditto.
* dll_main.cc: Ditto.
* dll_entry.cc: Ditto.
* getopt.c: Ditto.
* thread.cc (thread_init_wrapper): Call ExitThread explicitly rather than
returning, as a preliminary step towards placing per thread info at the bottom
of the stack.
* winsup.h: Move per_process class to include/sys/cygwin.h.  Declare new
dll_crt0().
* include/cygwin/version.h: Bump API minor version.
* binmode.c: New file.
* textmode.c: Ditto.
* lib/_cygwin_crt0_common.cc: Ditto.
* lib/crt0.h: Ditto.
* lib/cygwin_attach_dll.c: Ditto.
* lib/cygwin_crt0.c: Ditto.
* lib/dll_entry.cc: Ditto.
* lib/dll_main.cc: Ditto.
* lib/getopt.c: Ditto.
* lib/libcmain.c: Ditto.
* lib/premain0.c: Ditto.
* lib/premain1.c: Ditto.
* lib/premain2.c: Ditto.
* lib/premain3.c: Ditto.
2000-07-01 03:51:55 +00:00
Corinna Vinschen b3cc0634b9 * syscalls.cc (seteuid): Initialize pi.token before calling
internal_getlogin().
        * uinfo.cc (internal_getlogin): Use impersonation token instead
        of process token in case of active impersonation. Add some comments.
        (uinfo_init): Initializing myself->token and myself->impersonated
        before calling internal_getlogin(). Add some comments.
2000-06-28 17:42:28 +00:00
Christopher Faylor 5b082caa62 * windows.cc (setitimer): Round up when < 1000 usecs. 2000-06-26 22:33:54 +00:00
Christopher Faylor 9cef3cc0d7 * hinfo.cc (hinfo::dup2): Eliminate compiler warning. 2000-06-26 21:36:52 +00:00
Christopher Faylor 5a449743bb * hinfo.cc (hinfo::dup2): Guard against out of bounds newfd. 2000-06-26 15:27:12 +00:00
Christopher Faylor 84a1af74a2 * grp.cc (read_etc_group): Open file in text mode.
* pwd.cc (read_etc_passwd): Ditto.
* shared.h: Bump PROC_MAGIC.
2000-06-25 03:48:10 +00:00
Corinna Vinschen bb34ad9674 * fork.cc (fork): Fix error in copying SID pointer.
* spawn.cc (_spawnve): Ditto.
        * passwd.cc: Remove static from `passwd_in_memory_p'.
        (read_etc_passwd): Remove static.
        * uinfo.cc: Move global declaration of `read_etc_group' and
        `group_in_memory_p' into `uinfo_init'.
        (internal_getlogin): Try to get SID from current process first.
        (uinfo_init): Don't set uid and gid if `myself' has a valid SID.
        Only load /etc/passwd and /etc/group in that case.
2000-06-24 17:37:52 +00:00
Christopher Faylor 92b3b0a6ad * shared.cc (shared_info::initialize): Improve error message clarity.
* mkvers.sh: Eliminate debugging output.
2000-06-24 16:31:36 +00:00
Christopher Faylor d69257a1a4 * Makefile.in: Autogenerate cygwin.def when appropriate.
* include/sys/cygwin.h: Correct prototype.
2000-06-22 21:51:48 +00:00
Christopher Faylor d7cea2d3eb Revise previous include/sys/cygwin.h change. 2000-06-22 21:05:46 +00:00
Christopher Faylor f33acdb808 * include/sys/cygwin.h: Don't define parts of this file that rely on Windows
headers unless the Windows header was previously included.
2000-06-22 20:18:17 +00:00
Christopher Faylor 5af1047b41 Revert. 2000-06-22 19:48:10 +00:00
Christopher Faylor b867695801 Remove some files that were added prematurely. 2000-06-22 19:11:32 +00:00
Corinna Vinschen 98a3dc3bc5 * registry.cc (load_registry_hive): Use HKEY_USERS when checking
for existing user hive.
        Use MAX_PATH instead of numerical constant for array size.
        Use return code of RegLoadKeyA instead of GetLastError for error output.
2000-06-22 18:54:26 +00:00
Christopher Faylor 699dd00b3a * Makefile.in: Add new-libcygwin.a back to all_host target. 2000-06-22 18:28:16 +00:00
Christopher Faylor e282ff799f * Makefile.in: Add *.def to clean operation. 2000-06-21 18:33:19 +00:00
Christopher Faylor 159db33b11 * Makefile.in: Add *.exe to clean operation. 2000-06-21 17:20:47 +00:00
Christopher Faylor b2a2fdbaa7 Display what's going on. 2000-06-21 05:04:56 +00:00
Christopher Faylor 32454a4817 * mkvers.sh: Fix sed usage for older seds. 2000-06-21 05:03:36 +00:00
Christopher Faylor fb84fe4cbb * Makefile.in: Don't touch winver_stamp if mkvers.sh was unsuccessful. 2000-06-21 00:47:06 +00:00
Christopher Faylor 3ce7a5af5a * mkvers.sh: Fix problem with handling of CVS tags causing .rc syntax errors. 2000-06-20 21:42:25 +00:00
Christopher Faylor cfeb2c7d79 * Makefile.in: Change to build the DLL during a cross-compiler build. 2000-06-20 17:38:55 +00:00
Christopher Faylor a7874ee305 * select.cc (socket_cleanup): Shutdown I/O on dummy sockets prior to closing
them.
2000-06-20 00:47:52 +00:00
Corinna Vinschen e219a2bdf0 * dcrt0.cc: Add load statements for `GetSidIdentifierAuthority'
and `RegLoadKeyA'.
        * registry.cc (get_registry_hive_path): New function.
        (load_registry_hive): Ditto.
        * security.cc (convert_sid_to_string_sid): New function.
        (get_ssid): Renamed to `convert_string_sid_to_sid'.
        (get_pw_sid): Call `convert_string_sid_to_sid' instead of `get_ssid'.
        (get_gr_sid): Ditto.
        (get_admin_sid): Ditto.
        (get_system_sid): Ditto.
        (get_creator_owner_sid): Ditto.
        (get_world_sid): Ditto.
        * shared.h: New prototypes for `get_registry_hive_path' and
        `load_registry_hive'.
        * spawn.cc (spawn_guts): Set child->psid to NULL to force calling
        `internal_getlogin' from child process in case of changing user context.
        Call `load_registry_hive' in case of changing user context.
        (_spawnve): Copy user infos only if user context remains the same.
        * uinfo.cc: Add load statement for `NetUserGetInfo'.
        Remove load statement for `NetGetDCName'.
        (internal_getlogin): Rewrite to speed up process startup
        and to correct user environment in case user context changes.
        (uinfo_init): Call internal_getlogin only if myself->psid is NULL,
        that is user context changes.
        * winsup.h: Add prototypes for `convert_sid_to_string_sid',
        `convert_string_sid_to_sid' and `get_pw_sid'.
2000-06-19 17:36:30 +00:00
Christopher Faylor 6d4186757b * fhandler.h (set_name): Don't use 'unix' as name since this is defined by gcc
now.
* fhandler.cc (set_name): Ditto.
2000-06-18 17:43:45 +00:00
Christopher Faylor 42867d69ae * winsup.h (isabspath): Don't report `C:foo' as an absolute path. 2000-06-17 22:05:19 +00:00
Christopher Faylor e94903eb0f * configure.in: Detect "cross-hosting" situation and set appropriate variables
in Makefile to avoid building excess stuff.
* configure: Regenerate.
* Makefile.in: Accomodate above change.
2000-06-17 17:54:05 +00:00
Corinna Vinschen e46892585a * pinfo.cc (pinfo_init): Revert previous patch. 2000-06-17 17:53:08 +00:00
Corinna Vinschen 9bbb81a443 * pinfo.cc (pinfo_init): Add missing initializers.
* uinfo.cc (internal_getlogin): Request domain infos only
        when ntsec is ON.
2000-06-17 11:34:33 +00:00
Christopher Faylor e962f3c5f7 * Makefile.in: Just use library files from this tree when building cygrun.exe.
* path.cc (chdir): Don't set cache to offending chdir.  Change comment to
reflect current reality.
2000-06-16 23:39:02 +00:00
Corinna Vinschen 64b3062937 * cygwin.din: Define symbols for `cygwin_logon_user' and
`cygwin_set_impersonation_token'.
        * dcrt0.cc (dll_crt0_1): Eliminate superfluous conditional
        statements.
        Add load statements for `ImpersonateLoggedOnUser', `LogonUserA'
        and `RevertToSelf'.
        * fork.cc (fork): Care for correct impersonation of parent
        and child process.
        * security.cc (cygwin_set_impersonation_token): New function.
        (cygwin_logon_user): Ditto.
        shared.h (class pinfo): New members `orig_uid', `orig_gid',
        `real_uid' nad `real_gid'.
        spawn.cc (spawn_guts): Care for impersonation when starting
        child process in a different user context.
        * syscalls.cc (setgid): Call `setegid' now. Set real_gid.
        (setuid): Call `seteuid' now. Set real_uid.
        (seteuid): Functionality moved from setuid to here. Care for
        correct impersonation.
        (setegid): Functionality moved from setgid to here.
        * uinfo.cc (uinfo_init): Initialization of additional pinfo
        members.
        (getuid): Return real uid.
        (getgid): Return real gid.
        (geteuid): Return effective uid.
        (getegid): Return effective gid.
        include/sys/cygwin.h: Add prototypes for `cygwin_logon_user' and
        `cygwin_set_impersonation_token'.
        include/cygwin/version.h: Bumb API minor version to 22.
2000-06-16 19:36:07 +00:00
Christopher Faylor 3875d9e652 * path.cc (chdir): Don't set cache to offending chdir. Change comment to
reflect current reality.
2000-06-15 22:14:14 +00:00
Christopher Faylor 26cfd048e3 Fix typo. 2000-06-15 20:52:57 +00:00
Christopher Faylor 54ee424711 * path.cc (normalize_posix_path): Convert path to POSIX if it seems to be a
Windows path.
2000-06-15 19:44:50 +00:00
Christopher Faylor 48b1381da1 * environ.cc (conv_envvars): Detect and convert all environment variables used
by libiberty's choose-temp.c
2000-06-15 03:50:03 +00:00
Christopher Faylor 024afd70d6 * path.cc (mount_info::add_item): The previous patch can't handle the case of
overwriting a mount entry.
2000-06-13 16:48:37 +00:00
Christopher Faylor 00660f0110 * thread.h: Shorten "current_directory" variables to "cwd_*" throughout.
* path.cc: Ditto.
(normalize_posix_path): Add some extra debugging info.
(chdir): Ditto.  Store chdir'ed posix and MS-DOS directory names in "cache"
here rather than trying to derive them later.
2000-06-13 04:40:36 +00:00
Corinna Vinschen 7f4b6412be * fhandler_random.cc (read): Call CryptAquireContext with
CRYPT_VERIFYCONTEXT.
2000-06-11 14:01:18 +00:00
Corinna Vinschen af76c2eed1 * path.cc (path_conv::check): Erase two lines checked in
by mistake.
2000-06-08 20:51:11 +00:00
Corinna Vinschen b8a7c23a2a * fhandler.cc (fhandler_disk_file::open): Check for directory
to set O_DIROPEN on directories anyway.
2000-06-08 13:56:28 +00:00
Corinna Vinschen 95bdb4966f path.cc (mount_info::init): Eliminate the mount_slash feature.
(mount_slash): Eliminated.
        (mount_info::read_mounts): Eliminate looking up existing entries. The
        loop for deleting cygpath entries is done only when such entries exist.
        (mount_info::from_registry): Eliminate sorting.
        (mount_info::add_item): Call add_reg_mount if necessary. Check nmounts
        more precisely. Use strcasematch in looking up existing entries.
        (mount_info::del_item): Call del_reg_mount if necessary. Use
        strcasematch. Use memmove instead of memcpy.
        (mount_info::import_v1_registry): Everything is done in this method.
        (mount_info::to_registry): Eliminated.
        (mount_info::from_v1_registry): Eliminated.
        (cygwin_umount): Simply call del_item.
        shared.h: Modify the declaration of add_item and del_item. Remove the
        declaration of from_v1_registry.
2000-06-08 13:24:52 +00:00
Christopher Faylor fe73870ce5 * include/cygwin/version.h: Bump DLL minor version number to 3. 2000-06-08 03:58:51 +00:00
DJ Delorie 48b8705360 * cygwin.din: add cygwin_dll_init
* dcrt0.cc (cygwin_dll_init): new
(dll_crt0_1): short circuit if manually loaded
* path.cc (mount_info::init): don't init if manually loaded
2000-06-08 00:55:27 +00:00