2000-09-01 22:54:22 +02:00
|
|
|
/* 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. */
|
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
#include <setjmp.h>
|
|
|
|
|
2000-09-01 22:54:22 +02:00
|
|
|
enum
|
|
|
|
{
|
2001-10-05 06:37:33 +02:00
|
|
|
PROC_MAGIC = 0xaf12f000,
|
2001-10-10 04:32:12 +02:00
|
|
|
_PROC_EXEC = PROC_MAGIC + 2,
|
|
|
|
_PROC_SPAWN = PROC_MAGIC + 3,
|
|
|
|
_PROC_FORK = PROC_MAGIC + 4, // Newer versions provide stack
|
2000-09-01 22:54:22 +02:00
|
|
|
// location information
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PROC_MAGIC_MASK 0xff00f000
|
|
|
|
#define PROC_MAGIC_GENERIC 0xaf00f000
|
|
|
|
#define PROC_MAGIC_VER_MASK 0x0ff0000
|
|
|
|
|
2001-10-10 04:32:12 +02:00
|
|
|
#define PROC_EXEC (_PROC_EXEC + _cygwin_testing_magic)
|
|
|
|
#define PROC_SPAWN (_PROC_SPAWN + _cygwin_testing_magic)
|
|
|
|
#define PROC_FORK (_PROC_FORK + _cygwin_testing_magic)
|
|
|
|
|
2000-09-01 22:54:22 +02:00
|
|
|
#define EXEC_MAGIC_SIZE sizeof(child_info)
|
|
|
|
class child_info
|
|
|
|
{
|
|
|
|
public:
|
2001-09-20 22:58:29 +02:00
|
|
|
DWORD zero[4]; // must be zeroed
|
2000-09-01 22:54:22 +02:00
|
|
|
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
|
2001-01-28 06:51:15 +01:00
|
|
|
HANDLE mount_h;
|
2000-10-13 00:15:47 +02:00
|
|
|
HANDLE parent;
|
2000-11-06 07:36:32 +01:00
|
|
|
HANDLE pppid_handle;
|
2000-11-14 06:53:32 +01:00
|
|
|
init_cygheap *cygheap;
|
2000-10-13 00:15:47 +02:00
|
|
|
void *cygheap_max;
|
2001-07-17 05:41:52 +02:00
|
|
|
HANDLE cygheap_h;
|
2000-09-01 22:54:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2000-09-03 06:16:35 +02:00
|
|
|
class fhandler_base;
|
|
|
|
|
|
|
|
class cygheap_exec_info
|
|
|
|
{
|
|
|
|
public:
|
2000-10-17 01:55:58 +02:00
|
|
|
uid_t uid;
|
2000-09-03 06:16:35 +02:00
|
|
|
char *old_title;
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
2000-10-17 01:55:58 +02:00
|
|
|
int envc;
|
|
|
|
char **envp;
|
2000-09-03 06:16:35 +02:00
|
|
|
HANDLE myself_pinfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
class child_info_spawn: public child_info
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cygheap_exec_info *moreinfo;
|
2000-10-17 01:55:58 +02:00
|
|
|
HANDLE hexec_proc;
|
2000-09-03 06:16:35 +02:00
|
|
|
|
2000-10-13 00:15:47 +02:00
|
|
|
child_info_spawn (): moreinfo (NULL) {}
|
2000-09-03 06:16:35 +02:00
|
|
|
~child_info_spawn ()
|
|
|
|
{
|
|
|
|
if (parent)
|
|
|
|
CloseHandle (parent);
|
|
|
|
if (moreinfo)
|
|
|
|
{
|
|
|
|
if (moreinfo->old_title)
|
|
|
|
cfree (moreinfo->old_title);
|
2000-10-17 01:55:58 +02:00
|
|
|
if (moreinfo->envp)
|
2000-09-03 06:16:35 +02:00
|
|
|
{
|
2000-10-17 01:55:58 +02:00
|
|
|
for (char **e = moreinfo->envp; *e; e++)
|
2000-09-03 06:16:35 +02:00
|
|
|
cfree (*e);
|
2000-10-17 01:55:58 +02:00
|
|
|
cfree (moreinfo->envp);
|
2000-09-03 06:16:35 +02:00
|
|
|
}
|
|
|
|
CloseHandle (moreinfo->myself_pinfo);
|
|
|
|
cfree (moreinfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2000-09-01 22:54:22 +02:00
|
|
|
void __stdcall init_child_info (DWORD, child_info *, int, HANDLE);
|
|
|
|
|
|
|
|
extern child_info_fork *child_proc_info;
|