166b2571ce
* 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.
111 lines
2.4 KiB
C++
111 lines
2.4 KiB
C++
/* childinfo.h: shared child info for cygwin
|
|
|
|
Copyright 2000 Red Hat, Inc.
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
#include <setjmp.h>
|
|
|
|
enum
|
|
{
|
|
PROC_MAGIC = 0xaf09f000,
|
|
PROC_FORK = PROC_MAGIC + 1,
|
|
PROC_EXEC = PROC_MAGIC + 2,
|
|
PROC_SPAWN = PROC_MAGIC + 3,
|
|
PROC_FORK1 = PROC_MAGIC + 4, // Newer versions provide stack
|
|
// location information
|
|
PROC_SPAWN1 = PROC_MAGIC + 5
|
|
};
|
|
|
|
#define PROC_MAGIC_MASK 0xff00f000
|
|
#define PROC_MAGIC_GENERIC 0xaf00f000
|
|
#define PROC_MAGIC_VER_MASK 0x0ff0000
|
|
|
|
#define EXEC_MAGIC_SIZE sizeof(child_info)
|
|
class child_info
|
|
{
|
|
public:
|
|
DWORD zero[1]; // must be zeroed
|
|
DWORD cb; // size of this record
|
|
DWORD type; // type of record
|
|
int cygpid; // cygwin pid of child process
|
|
HANDLE subproc_ready; // used for synchronization with parent
|
|
HANDLE shared_h;
|
|
HANDLE console_h;
|
|
HANDLE parent_alive; // handle of thread used to track children
|
|
HANDLE parent;
|
|
void *cygheap;
|
|
void *cygheap_max;
|
|
};
|
|
|
|
class child_info_fork: public child_info
|
|
{
|
|
public:
|
|
HANDLE forker_finished;// for synchronization with child
|
|
DWORD stacksize; // size of parent stack
|
|
void *heaptop;
|
|
void *heapbase;
|
|
void *heapptr;
|
|
jmp_buf jmp; // where child will jump to
|
|
void *stacktop; // location of top of parent stack
|
|
void *stackbottom; // location of bottom of parent stack
|
|
};
|
|
|
|
class fhandler_base;
|
|
|
|
class cygheap_exec_info
|
|
{
|
|
public:
|
|
uid_t uid;
|
|
char *old_title;
|
|
fhandler_base **fds;
|
|
size_t nfds;
|
|
int argc;
|
|
char **argv;
|
|
int envc;
|
|
char **envp;
|
|
HANDLE myself_pinfo;
|
|
char *cwd_posix;
|
|
char *cwd_win32;
|
|
DWORD cwd_hash;
|
|
};
|
|
|
|
class child_info_spawn: public child_info
|
|
{
|
|
public:
|
|
cygheap_exec_info *moreinfo;
|
|
HANDLE hexec_proc;
|
|
|
|
child_info_spawn (): moreinfo (NULL) {}
|
|
~child_info_spawn ()
|
|
{
|
|
if (parent)
|
|
CloseHandle (parent);
|
|
if (moreinfo)
|
|
{
|
|
if (moreinfo->old_title)
|
|
cfree (moreinfo->old_title);
|
|
if (moreinfo->cwd_posix)
|
|
cfree (moreinfo->cwd_posix);
|
|
if (moreinfo->cwd_win32)
|
|
cfree (moreinfo->cwd_win32);
|
|
if (moreinfo->envp)
|
|
{
|
|
for (char **e = moreinfo->envp; *e; e++)
|
|
cfree (*e);
|
|
cfree (moreinfo->envp);
|
|
}
|
|
CloseHandle (moreinfo->myself_pinfo);
|
|
cfree (moreinfo);
|
|
}
|
|
}
|
|
};
|
|
|
|
void __stdcall init_child_info (DWORD, child_info *, int, HANDLE);
|
|
|
|
extern child_info_fork *child_proc_info;
|