summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
Commit message (Collapse)AuthorAgeFilesLines
* Throughout, change 'cygwin_shared.mount' to 'mount_table'.Christopher Faylor2001-01-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * child_info.h (child_info): Move shared_h, console_h to cygheap. Add mount_h. * cygheap.h (init_cygheap): Add shared_h, console_h. * cygheap.cc (init_cheap): Initialize heap at a fixed location after the shared memory regions. Initialize cygheap->user name here. * dcrt0.cc (dll_crt0_1): Call getpagesize () to initialize constants. Remove cygheap_init since it is done in shared_init now. (_dll_crt0): Initialize mount_h, remove shared_h and console_h initialization. * fhandler_console.cc (console_shared_h): Eliminate. (get_tty_stuff): Use cygheap->console_h rather than console_shared_h. * heap.cc (heap_init): Use page size constant calculated earlier in initialization. * shared.cc: Eliminate cygwin_shared_h. Add cygwin_mount_h. (mount_table_init): New function for initializing a user mount table. (open_shared_file_map): Use constant for shared memory region. Initialize cygheap and mount table here. (open_shared): Improve debugging output. (shared_info::initialize): Eliminate call to mount.init. (shared_terminate): Use cygheap->shared_h. Close cygwin_mount_h. (open_shared_file_map): Eliminate. * shared_info.h (mount_info): Add a version field. (shared_align_past): New macro for calculating location for shared memory regions. * sigproc.cc (init_child_info): Eliminate shared_h, console_h. * spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different user. * syscalls.cc (system_info): New global holding system memory defaults. (getpagesize): Use system_info. * uinfo.cc (internal_getlogin): Only fill in user name if nonexistent. * winsup.h: Declare system_info. * passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than retrieving the name again.
* * spawn.cc (spawn_guts): Quoting was still wrong. Keep trying to fix it.Christopher Faylor2000-11-201-6/+20
|
* * spawn.cc (spawn_guts): YA tweak for dealing with arcane rules of quoting inChristopher Faylor2000-11-201-1/+6
| | | | | | "normal" Microsoft programs. * child_info.h: Bump fork magic number. * include/sys/mount.h: Add an entry for mixed mode.
* * cygheap.h: Move `token' and `impersonated' from class _pinfoCorinna Vinschen2000-11-151-5/+7
| | | | | | | | | | | | | to class cygheap_user. * pinfo.h: Ditto. * fork.cc (fork_child): Change usage of `token' and `impersonated' accordingly. (fork_parent): Ditto. * security.cc (cygwin_set_impersonation_token): Ditto. * sigproc.cc (proc_subproc): Ditto. * spawn.cc (spawn_guts): Ditto. * syscalls.cc (seteuid): Ditto. * uinfo.cc (uinfo_init): Ditto.
* * spawn.cc (spawn_guts): Revert patch to ignore chroot settingsCorinna Vinschen2000-11-151-6/+1
| | | | on creating native Win32 environment.
* Throughout use myself->ppid_handle rather than parent_alive.Christopher Faylor2000-11-151-26/+13
| | | | | | | | | | | | | | | | * 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.
* * cygheap.cc (cygheap_root::cygheap_root): New function.Corinna Vinschen2000-11-151-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* * environ.cc (_addenv): malloc space for setenv if cygwin1.dll is used inChristopher Faylor2000-11-081-1/+1
| | | | | | | | | | | | | | | | | | 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.
* * child_info.h (child_info): Add pppid_handle for closing the parent's of theChristopher Faylor2000-11-061-21/+2
| | | | | | | | | | | | | | | | | | | | | | | 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.
* * pinfo.cc (EnumProcessesNT): Avoid 0 pids.Christopher Faylor2000-11-041-0/+1
| | | | | | | | | | (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.
* Whitespace cleanup.Christopher Faylor2000-10-281-1/+1
| | | | | | * configure.in: Eliminate subdir stuff. * configure: Regenerate. * include/getopt.h (option): Make name field 'const'.
* * dtable.cc (dtable::release): Check for socket. ChangeCorinna Vinschen2000-10-261-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * dcrt0.cc (do_exit): Don't bother looking for pgrp children to send SIGHUP ifChristopher Faylor2000-10-251-0/+1
| | | | | | | | | | 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.
* * exceptions.cc (signal_exit): Kill any executing child process if we're dying.Christopher Faylor2000-10-241-2/+5
| | | | | | | | | | * 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.
* * spawn.cc (spawn_guts): Don't do the reparenting step if we notice that theChristopher Faylor2000-10-211-5/+1
| | | | | child has exited prior to sending the subprocess_ready signal (?).
* * fhandler.h (fhandler_console): Remove tcsetpgrp.Christopher Faylor2000-10-211-0/+2
| | | | | | | | | | | | * 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.
* * external.cc (fillout_pinfo): Pass PID_NOREDIR flag to pinfo init to avoidChristopher Faylor2000-10-201-11/+17
| | | | | | | | 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.
* * Makefile.in: Remove some obsolete stuff.Christopher Faylor2000-10-161-66/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* * exceptions.cc (set_console_handler): Don't allocateChristopher Faylor2000-10-151-29/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * cygheap.cc (cygheap_fixup_in_child): Don't page round cygheap copied fromChristopher Faylor2000-10-141-123/+98
| | | | | | | | | | | | | | | | | | 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.
* * errno.cc (seterrno_from_win_error): Fix debugging output.Christopher Faylor2000-10-121-1/+2
| | | | | | | | | | | | | | * 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.
* * dtable.cc (set_std_handle): Use std_consts array to control SetStdHandleChristopher Faylor2000-10-091-32/+28
| | | | | | | | | | | | | | | | | | | | | | | 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.
* * path.cc (symlink_info::check): Set executable bit for a file if the first twoChristopher Faylor2000-09-301-3/+3
| | | | characters are 'MZ' to mirror spawn_guts check.
* * spawn.cc (spawn_guts): Attempt to accomodate archaic windows quotingChristopher Faylor2000-09-271-9/+9
| | | | mechanism when dealing with '\' and '"'.
* * dcrt0.cc (quoted): Fix problem where ' quoted strings were skipped.Christopher Faylor2000-09-261-1/+1
| | | | | | | | | * 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.
* * spawn.cc (av::dup_maybe): Make function void rather than void *.Christopher Faylor2000-09-251-1/+1
| | | | | | | | | * 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'.
* * spawn.cc (spawn_guts): Use actual program argument passed in for argv[0] asChristopher Faylor2000-09-191-1/+1
| | | | originally suggested by Kazuhiro Fujieda <fujieda@jaist.ac.jp>.
* * spawn.cc (av): Hide 'calloced' field and limit cstrduping to class methodsChristopher Faylor2000-09-131-14/+35
| | | | | | | | | | | | | 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>.
* Break out more header info into separate files. Use appropriate header filesChristopher Faylor2000-09-081-0/+5
| | | | | | | | | | | | 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.
* * sigproc.cc: Add include file for proper definitions.Christopher Faylor2000-09-061-1/+1
| | | | | * spawn.cc: Ditto. * winsup.h: Define cfree to avoid newlib pollution.
* * path.cc (cwd_win32): Eliminate.Christopher Faylor2000-09-051-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* * path.cc (readlink): Check if buffer length is positive. Truncate output toChristopher Faylor2000-09-041-1/+1
| | | | buffer length. Don't terminate buffer with '\0'.
* * Makefile.in: Add cygheap.o.Christopher Faylor2000-09-031-233/+256
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* * sigproc.cc (proc_info): Rename proc_exists which takes a pid to "pid_exists".Christopher Faylor2000-09-011-0/+1
| | | | | | * shared.h: Split out "child_info" stuff into a new header file and use where necessary. Declare pid_exists. * child_info.h: New file.
* * dcrt0.cc (dll_crt0_1): Move set_os_type.Christopher Faylor2000-08-261-9/+8
| | | | | | | | | | | (_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.
* * dcrt0.cc (dll_crt0_1): Move exception list and constructor stuff earlier inChristopher Faylor2000-08-241-1/+8
| | | | | | | | | | | | | | 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.
* Revert previous erroneous checkin.Christopher Faylor2000-08-231-4/+0
|
* * include/sys/cygwin.h: Protect class definitions.Christopher Faylor2000-08-231-0/+4
|
* * winsup.h: Eliminate inclusion of most of the cygwin .h files. Use .h filesChristopher Faylor2000-08-221-1/+6
| | | | | only in sources which require them. * Makefile.in: Generate dependencies with -MD option.
* * cygerrno.h: New file. Use this throughout whenever errno manipulation isChristopher Faylor2000-08-221-0/+1
| | | | | | | | | | | | | | | 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 /.
* * winsup.h: Split out dtable definitions into separate header file.Christopher Faylor2000-08-121-1/+3
| | | | | | * dtable.h: New file. * sigproc.h: Eliminate pinfo.h usage here. Use it in source files that need it.
* Rename hinfo -> dtable. Name the former dtable array 'fdtab'.Christopher Faylor2000-08-121-3/+3
|
* * select.cc (allocfd_set): Zero allocated fd_set.Christopher Faylor2000-08-091-4/+6
| | | | | | | | | | | | | | (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.
* * fork.cc (vfork): Store complete stack frame in vfork_save structure for laterChristopher Faylor2000-08-031-9/+10
| | | | | | | | | | 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.
* * winsup.h: take out protections of environ, errno, allow C useDJ Delorie2000-08-021-5/+5
| | | | | | | | | | * *.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.
* * include/cygwin/version.h: Bump DLL minor version number to 5 due to all ofChristopher Faylor2000-07-291-69/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * testsuite/winsup.api/winsup.exp: ignore stdout by defaultDJ Delorie2000-07-271-0/+2
| | | | | | | | | | | | | | | | | | | * 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
* * spawn.cc (span_guts): Retrieve security attributes before settingCorinna Vinschen2000-07-211-6/+8
| | | | psid to NULL.
* * spawn.cc (spawn_guts): Don't restore impersonation in caseCorinna Vinschen2000-07-191-6/+6
| | | | of _P_OVERLAY. Clean up slightly. Accomodate comments.
* * shared.h (class pinfo): New members `root' and `rootlen'.Corinna Vinschen2000-07-191-0/+2
| | | | | | | | | | | | | | | | * 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.