2000-09-02 04:54:22 +08:00
|
|
|
/* childinfo.h: shared child info for cygwin
|
|
|
|
|
* child_info.h, cygheap.h, fhandler_clipboard.cc, fhandler_dsp.cc,
fhandler_floppy.cc, fhandler_mem.cc, fhandler_random.cc,
fhandler_tape.cc, fhandler_zero.cc, grp.cc, mmap.cc, passwd.cc,
pinfo.cc, pinfo.h, pipe.cc, sec_acl.cc, sec_helper.cc, security.cc,
security.h, thread.h, uinfo.cc, include/cygwin/acl.h: Fix copyright.
2002-02-10 21:50:13 +08:00
|
|
|
Copyright 2000, 2002 Red Hat, Inc.
|
2000-09-02 04:54:22 +08:00
|
|
|
|
|
|
|
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 10:56:55 +08:00
|
|
|
#include <setjmp.h>
|
|
|
|
|
2000-09-02 04:54:22 +08:00
|
|
|
enum
|
|
|
|
{
|
2001-12-26 12:53:34 +08:00
|
|
|
_PROC_EXEC,
|
|
|
|
_PROC_SPAWN,
|
|
|
|
_PROC_FORK
|
2000-09-02 04:54:22 +08:00
|
|
|
};
|
|
|
|
|
2001-12-26 12:53:34 +08:00
|
|
|
#define OPROC_MAGIC_MASK 0xff00ff00
|
|
|
|
#define OPROC_MAGIC_GENERIC 0xaf00f000
|
2000-09-02 04:54:22 +08:00
|
|
|
|
2001-12-26 12:53:34 +08:00
|
|
|
#define PROC_MAGIC_GENERIC 0xaf00fa00
|
|
|
|
|
|
|
|
#define PROC_EXEC (_PROC_EXEC)
|
|
|
|
#define PROC_SPAWN (_PROC_SPAWN)
|
|
|
|
#define PROC_FORK (_PROC_FORK)
|
2001-10-10 10:32:12 +08:00
|
|
|
|
2000-09-02 04:54:22 +08:00
|
|
|
#define EXEC_MAGIC_SIZE sizeof(child_info)
|
2001-12-26 12:53:34 +08:00
|
|
|
|
2002-06-06 09:31:16 +08:00
|
|
|
#define CURR_CHILD_INFO_MAGIC 0xaec3
|
2001-12-26 12:53:34 +08:00
|
|
|
|
2001-12-26 14:18:41 +08:00
|
|
|
/* NOTE: Do not make gratuitous changes to the names or organization of the
|
|
|
|
below class. The layout is checksummed to determine compatibility between
|
|
|
|
different cygwin versions. */
|
2000-09-02 04:54:22 +08:00
|
|
|
class child_info
|
|
|
|
{
|
|
|
|
public:
|
2001-09-21 04:58:29 +08:00
|
|
|
DWORD zero[4]; // must be zeroed
|
2000-09-02 04:54:22 +08:00
|
|
|
DWORD cb; // size of this record
|
2001-12-26 12:53:34 +08:00
|
|
|
DWORD intro; // improbable string
|
|
|
|
unsigned short magic; // magic number unique to child_info
|
|
|
|
unsigned short type; // type of record, exec, spawn, fork
|
2000-09-02 04:54:22 +08:00
|
|
|
int cygpid; // cygwin pid of child process
|
|
|
|
HANDLE subproc_ready; // used for synchronization with parent
|
2001-01-28 13:51:15 +08:00
|
|
|
HANDLE mount_h;
|
2000-10-13 06:15:47 +08:00
|
|
|
HANDLE parent;
|
2000-11-06 14:36:32 +08:00
|
|
|
HANDLE pppid_handle;
|
2000-11-14 13:53:32 +08:00
|
|
|
init_cygheap *cygheap;
|
2000-10-13 06:15:47 +08:00
|
|
|
void *cygheap_max;
|
2001-07-17 11:41:52 +08:00
|
|
|
HANDLE cygheap_h;
|
2001-12-27 05:35:16 +08:00
|
|
|
unsigned fhandler_union_cb;
|
2000-09-02 04:54:22 +08: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 12:16:35 +08:00
|
|
|
class fhandler_base;
|
|
|
|
|
|
|
|
class cygheap_exec_info
|
|
|
|
{
|
|
|
|
public:
|
2002-05-29 23:04:29 +08:00
|
|
|
__uid32_t uid;
|
2000-09-03 12:16:35 +08:00
|
|
|
char *old_title;
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
2000-10-17 07:55:58 +08:00
|
|
|
int envc;
|
|
|
|
char **envp;
|
2000-09-03 12:16:35 +08:00
|
|
|
HANDLE myself_pinfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
class child_info_spawn: public child_info
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cygheap_exec_info *moreinfo;
|
2000-10-17 07:55:58 +08:00
|
|
|
HANDLE hexec_proc;
|
2000-09-03 12:16:35 +08:00
|
|
|
|
2000-10-13 06:15:47 +08:00
|
|
|
child_info_spawn (): moreinfo (NULL) {}
|
2000-09-03 12:16:35 +08:00
|
|
|
~child_info_spawn ()
|
|
|
|
{
|
|
|
|
if (parent)
|
|
|
|
CloseHandle (parent);
|
|
|
|
if (moreinfo)
|
|
|
|
{
|
|
|
|
if (moreinfo->old_title)
|
|
|
|
cfree (moreinfo->old_title);
|
2000-10-17 07:55:58 +08:00
|
|
|
if (moreinfo->envp)
|
2000-09-03 12:16:35 +08:00
|
|
|
{
|
2000-10-17 07:55:58 +08:00
|
|
|
for (char **e = moreinfo->envp; *e; e++)
|
2000-09-03 12:16:35 +08:00
|
|
|
cfree (*e);
|
2000-10-17 07:55:58 +08:00
|
|
|
cfree (moreinfo->envp);
|
2000-09-03 12:16:35 +08:00
|
|
|
}
|
|
|
|
CloseHandle (moreinfo->myself_pinfo);
|
|
|
|
cfree (moreinfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2000-09-02 04:54:22 +08:00
|
|
|
void __stdcall init_child_info (DWORD, child_info *, int, HANDLE);
|
|
|
|
|
|
|
|
extern child_info_fork *child_proc_info;
|