Commit Graph

61 Commits

Author SHA1 Message Date
Christopher Faylor 84aeff4126 Throughout use myself->ppid_handle rather than parent_alive.
* child_info.h (child_info): Eliminate parent_alive.
* dcrt0.cc (dll_crt0_1): Call fork_init for debugging pid creation.
* fork.cc (fork_child): Reflect change to fixup_mmaps_after_fork arguments.
(slow_pid_reuse): New function to grab last 'n' pids to prevent pid reuse.
(fork_parent): Move last_fork_proc into slow_pid_reuse.  Handle fork_pids
debugging.  Eliminate unnecessary call to set_child_mmap_ptr.
(fork_init): New debugging function.
* mmap.cc (fixup_mmaps_after_fork): Renamed from recreate_mmaps_after_fork.
Rely on copied data after a fork.
(set_child_mmap_ptr): Eliminate.
* pinfo.h (_pinfo): Eliminate parent_alive, mmap_ptr and reflect above changes.
* spawn.cc (spawn_guts): Eliminate vestiges of "old way" of sending new hProc
to parent process.
2000-11-15 06:27:48 +00:00
Corinna Vinschen 1f0f8e127c * cygheap.cc (cygheap_root::cygheap_root): New function.
(cygheap_root::~cygheap_root): Ditto.
        (cygheap_root::operator=): Ditto.
        (cygheap_user::~cygheap_user): Ditto.
        (cygheap_user::set_name): Ditto.
        (cygheap_user::set_logsrv): Ditto.
        (cygheap_user::set_domain): Ditto.
        (cygheap_user::set_sid): Ditto.
        * cygheap.h (cygheap_root): New class.
        (cygheap_user): Ditto.
        (init_cygheap): Change type of `root' member to cygheap_root.
        Add `user' member.
        * dir.cc (opendir): Use new `cygheap_root' class.
        * dcrt0.cc (dll_crt0_1): Use new `cygheap_user' class.
        * fork.cc (fork_parent): Ditto.
        * grp.cc (getgroups): Ditto.
        * passwd.cc (search_for): Ditto.
        * path.cc: Use new `cygheap_root' class throughout.
        * pinfo.h (_pinfo): Remove `use_psid'. Move `username', `psid',
        `logsrv', `domain', `orig_{uid,gid}' and `real_{uid,gid}' to
        cygheap_user class.
        * security.cc: Use new `cygheap_user' class throughout.
        * shared.cc (sec_user): Ditto.
        * sigproc.cc (proc_subproc): Remove copy statements for user
        related information moved to `cygheap_user' class.
        * spawn.cc (spawn_guts): Invalidate current chroot settings
        when creating Windows environment. Use new `cygheap_user' class.
        * syscalls.cc: Use new `cygheap_user' class throughout.
        * uinfo.cc: Ditto.
        * uinfo.cc (internal_getlogin): Change parameters to reflect the
        move of user information to cygheap.
2000-11-15 00:13:09 +00:00
Christopher Faylor 9bc846bd3d * environ.cc (_addenv): malloc space for setenv if cygwin1.dll is used in
conjunction with older binaries.
(environ_init): Ditto.
* external.cc (get_cygdrive_info): New function.
* external.cc (get_cygdrive_prefixes): Change to use get_cygdrive_info but toss
the user and system flags.
* external.cc (cygwin_internal): Add new CW_GET_CYGDRIVE_INFO case.
* path.cc (mount_info::get_cygdrive_prefixes): Remove method.
* path.cc (mount_info::get_cygdrive_info): New method.  Actually,
get_cygdrive_info is really an enhanced version of get_cygdrive_prefixes
renamed to get_cygdrive_info that also gets the user and system flags.
* shared_info.h (get_cygdrive_prefixes): Remove method.
* shared_info.h (get_cygdrive_info): New method.
* include/cygwin/version.h: Bump minor API version due to adding
CW_GET_CYGDRIVE_INFO to cygwin_internal.
* include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GET_CYGDRIVE_INFO.
2000-11-08 20:36:37 +00:00
Christopher Faylor dd11f11fae * child_info.h (child_info): Add pppid_handle for closing the parent's of the
parent handle.
* dcrt0.cc (_dll_crt0): Close parent's parent handle when spawned or forked.
* debug.cc (add_handle): Correct erroneous reference to handle structure when
printing warning.
* exceptions.cc (interrupt_now): Always return 1.
(interrupt_on_return): Accept a sigthread argument.  Check to see if this
argument has been trashed prior to setting up the stack return.
(call_handler): Add a loop around attempts to dispatch signals to detect case
where interrupt_on_return fails.
(_sigdelayed): Set up a temporary frame pointer prior to calling stuff that
could trigger an interrupt or the stack walking code will be very confused.
* fork.cc (fork_parent): Move a lot of the setup of the child process into
proc_subproc.
* spawn.cc (spawn_guts): Ditto.  Use ppid_handle to contact logical parent when
reparenting.
* pinfo.h (_pinfo): Remember the logical handle of the parent process.
* sigproc.cc (proc_subproc): Record most stuff necessary for the _pinfo
structure that is inferrable from myself when adding children.
(wait_sig): Always set 'pending_signals' flag when about to kick off the signal
scanning loop.  Reset it only if there are no pending signals.
2000-11-06 06:36:32 +00:00
Christopher Faylor e46db834d9 * pinfo.cc (EnumProcessesNT): Avoid 0 pids.
(EnumProcesses9x): Ditto.
* sigproc.cc (remove_childe): Eliminate.
(proc_subproc): Move remove_child stuff here.
(wait_subproc): Synchronize with proc_subproc when error occurs.  Add more
debugging info.
* sigproc.h (procstuff): Add an entry.
* spawn.cc (spawn_guts): Add sigframe here.
2000-11-04 05:54:57 +00:00
Christopher Faylor 75a57bf04a Whitespace cleanup.
* configure.in: Eliminate subdir stuff.
* configure: Regenerate.
* include/getopt.h (option): Make name field 'const'.
2000-10-28 05:41:44 +00:00
Corinna Vinschen dd4f0b2343 * dtable.cc (dtable::release): Check for socket. Change
cnt_need_fixup_before accordingly.
        (dtable::dup2): Ditto.
        (dtable::fixup_before_fork): New method.
        (dtable::fixup_before_exec): Ditto.
        * dtable.h (class dtable): Add member `cnt_need_fixup_before'. Add
        definition for methods `dec_need_fixup_before', `inc_need_fixup_before',
        `need_fixup_before', `fixup_before_exec' and `fixup_before_fork'.
        * fhandler.h (class fhandler_base): Slight rearrangements. Add
        definitions for methods `fixup_before_fork_exec'.
        (class fhandler_socket): Eliminate superfluous constructor.
        Add member `prot_info_ptr'. Add destructor. Add definitions for
        methods `dup', `fixup_before_fork_exec', `fixup_after_fork' and
        `fixup_after_exec'.
        * fork.cc (fork_parent): Care for file types which need a fixup
        before fork. Start child in suspended state then.
        * net.cc: New global variable `ws2_32_handle' and `wsadata'.
        (fdsock): Check for Winsock version. Call `set_socket_inheritance'
        only if Winsock version < 2.0. Care for `need_fixup' count in fdtab.
        (cygwin_socket): Eliminate call to `set_socket_inheritance'.
        (cygwin_accept): Ditto.
        (cygwin_rcmd): Ditto.
        (cygwin_rresvport): Ditto.
        (cygwin_rexec): Ditto.
        (socketpair): Ditto.
        (fhandler_socket::fhandler_socket): Set `need_fork_fixup'. Allocate
        space for the WSAPROTOCOL_INFOA struct used in fixup.
        (fhandler_socket::~fhandler_socket): New destructor.
        (fhandler_socket::fixup_before_fork_exec): New method.
        (fhandler_socket::fixup_after_fork): Ditto.
        (fhandler_socket::dup): Ditto.
        (wsock_init): New static function.
        (LoadDLLinitfunc (wsock32)): Rearranged.
        (LoadDLLinitfunc (ws2_32)): New function.
        (dummy_autoload): Add autoload statemants for `WSADuplicateSocketA'
        and `WSASocketA'.
        * spawn.cc (spawn_guts): Care for file types which need a fixup
        before exec. Start child in suspended state then.
2000-10-26 10:13:41 +00:00
Christopher Faylor f8f9b12e6c * dcrt0.cc (do_exit): Don't bother looking for pgrp children to send SIGHUP if
process has never created any children.
* fork.cc (fork): Set flag indicating that there is another process with our
process group.
* spawn.cc (spawn_guts): Ditto.
* pinfo.h (set_has_pgid_children): New methods for setting when process has
children in its process group.
* syscalls.cc (setpgid): Clear has_gid_children if pgid changes.
2000-10-25 03:54:50 +00:00
Christopher Faylor 4c45a89744 * exceptions.cc (signal_exit): Kill any executing child process if we're dying.
* path.h: Remove unneeded extern.
* spawn.cc (std_suffixes): Make static.  Don't set dwProcessId here since it
makes the process unsignalable.  Set strace flag that this is an execed process
stub.
* strace.cc (strace::vsprntf): Use strace flag to indicate when to visually
flag that this is an exec stub.
* include/sys/strace.h (strace): Add 'execing' flag.
2000-10-24 02:25:27 +00:00
Christopher Faylor eca7c7291f * spawn.cc (spawn_guts): Don't do the reparenting step if we notice that the
child has exited prior to sending the subprocess_ready signal
(?).
2000-10-21 05:53:43 +00:00
Christopher Faylor b0de2aa284 * fhandler.h (fhandler_console): Remove tcsetpgrp.
* fhandler_console.cc (fhandler_console::tcsetpgrp): Eliminate.
* fork.cc (fork_parent): Avoid returning same pid twice in a row regardless of
OS.
* pinfo.cc (pinfo::init): Rename create argument to flags and treat it as such.
* signal.cc (set_sigcatchers): New function.
(signal): Use set_sigcatchers to increment or decrement sigcatcher tracker.
(sigaction): Ditto.  Add debugging output.
* spawn.cc (spawn_guts): Always quote first argv[0] argument when it's a
COMSPEC shell.
2000-10-21 04:53:49 +00:00
Christopher Faylor a333dca2b8 * external.cc (fillout_pinfo): Pass PID_NOREDIR flag to pinfo init to avoid
finding execed processes twice.
* signal.cc (kill_pgrp): Ditto.
* spawn.cc (spawn_guts): Avoid passing first argument to CreateProcess when
running a windows shell so that CreateProcess will locate the shell.
Reorganize so that correct error is returned when CreateProcess fails.
2000-10-20 04:20:21 +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
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 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 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 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
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 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 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 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 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 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 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 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
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 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 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 9015e0fb8c Rename hinfo -> dtable. Name the former dtable array 'fdtab'. 2000-08-12 04:48:44 +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
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 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 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
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
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 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 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
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 8e382d8049 * spawn.cc (spawn_guts): Use \ for quoting '"'.
* dcrt0.cc (quoted): Understand \ quoting for '"'.
2000-07-16 06:31:06 +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
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