57013c31ec
* child_info.h: Rename PROC_* to _PROC_*. Define PROC_* with additional testing magic. Eliminate old PROC_FORK and rename PROC_FORK1 to PROC_FORK. * dcrt0.cc (_cygwin_testing_magic): New variable. Added to magic number in proc_info. (alloc_stack): Eliminate old PROC_FORK test. (dll_crt0_1): Ditto. Use _PROC_* enums for test. Subtract _cygwin_testing_magic from child_proc_info->type so that normal cygwin programs invoked by test suite programs do not consider themselves to be in a cygwin environment. (_dll_crt0): Ditto. Move environment checks to initial_env function to conserve on stack space. (initial_env): New function. Checks for testing and debugging environment variables. * init.cc (cygwin_hmodule): Move declaration. * winsup.h: Declare variables used for cygwin testing.
104 lines
2.2 KiB
C++
104 lines
2.2 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 = 0xaf12f000,
|
|
_PROC_EXEC = PROC_MAGIC + 2,
|
|
_PROC_SPAWN = PROC_MAGIC + 3,
|
|
_PROC_FORK = PROC_MAGIC + 4, // Newer versions provide stack
|
|
// location information
|
|
};
|
|
|
|
#define PROC_MAGIC_MASK 0xff00f000
|
|
#define PROC_MAGIC_GENERIC 0xaf00f000
|
|
#define PROC_MAGIC_VER_MASK 0x0ff0000
|
|
|
|
#define PROC_EXEC (_PROC_EXEC + _cygwin_testing_magic)
|
|
#define PROC_SPAWN (_PROC_SPAWN + _cygwin_testing_magic)
|
|
#define PROC_FORK (_PROC_FORK + _cygwin_testing_magic)
|
|
|
|
#define EXEC_MAGIC_SIZE sizeof(child_info)
|
|
class child_info
|
|
{
|
|
public:
|
|
DWORD zero[4]; // 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;
|
|
HANDLE cygheap_h;
|
|
};
|
|
|
|
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;
|
|
int argc;
|
|
char **argv;
|
|
int envc;
|
|
char **envp;
|
|
HANDLE myself_pinfo;
|
|
};
|
|
|
|
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->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;
|