2a6fc028ba
* 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.
110 lines
2.3 KiB
C++
110 lines
2.3 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 = 0xaf0cf000,
|
|
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 mount_h;
|
|
HANDLE parent;
|
|
HANDLE pppid_handle;
|
|
init_cygheap *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;
|