OSDN Git Service

Break out more header info into separate files. Use appropriate header files
[pf3gnuchains/pf3gnuchains3x.git] / winsup / cygwin / child_info.h
1 /* childinfo.h: shared child info for cygwin
2
3    Copyright 2000 Red Hat, Inc.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 #include <setjmp.h>
12
13 enum
14 {
15   PROC_MAGIC = 0xaf08f000,
16   PROC_FORK = PROC_MAGIC + 1,
17   PROC_EXEC = PROC_MAGIC + 2,
18   PROC_SPAWN = PROC_MAGIC + 3,
19   PROC_FORK1 = PROC_MAGIC + 4,  // Newer versions provide stack
20                                 // location information
21   PROC_SPAWN1 = PROC_MAGIC + 5
22 };
23
24 #define PROC_MAGIC_MASK 0xff00f000
25 #define PROC_MAGIC_GENERIC 0xaf00f000
26 #define PROC_MAGIC_VER_MASK 0x0ff0000
27
28 #define EXEC_MAGIC_SIZE sizeof(child_info)
29 class child_info
30 {
31 public:
32   DWORD zero[1];        // must be zeroed
33   DWORD cb;             // size of this record
34   DWORD type;           // type of record
35   int cygpid;           // cygwin pid of child process
36   HANDLE subproc_ready; // used for synchronization with parent
37   HANDLE shared_h;
38   HANDLE console_h;
39   HANDLE parent_alive;  // handle of thread used to track children
40 };
41
42 class child_info_fork: public child_info
43 {
44 public:
45   HANDLE forker_finished;// for synchronization with child
46   DWORD stacksize;      // size of parent stack
47   void *heaptop;
48   void *heapbase;
49   void *heapptr;
50   jmp_buf jmp;          // where child will jump to
51   void *stacktop;       // location of top of parent stack
52   void *stackbottom;    // location of bottom of parent stack
53 };
54
55 class fhandler_base;
56
57 class cygheap_exec_info
58 {
59 public:
60   char *old_title;
61   fhandler_base **fds;
62   size_t nfds;
63   int argc;
64   char **argv;
65   char **environ;
66   HANDLE myself_pinfo;
67   char *cwd_posix;
68   char *cwd_win32;
69   DWORD cwd_hash;
70 };
71
72 class child_info_spawn: public child_info
73 {
74 public:
75   HANDLE parent;
76   void *cygheap;
77   void *cygheap_max;
78   cygheap_exec_info *moreinfo;
79
80   child_info_spawn (): parent (NULL), cygheap (NULL),
81     cygheap_max (NULL), moreinfo (NULL) {}
82   ~child_info_spawn ()
83   {
84     if (parent)
85       CloseHandle (parent);
86     if (moreinfo)
87       {
88         if (moreinfo->old_title)
89           cfree (moreinfo->old_title);
90         if (moreinfo->environ)
91           {
92             for (char **e = moreinfo->environ; *e; e++)
93               cfree (*e);
94             cfree (moreinfo->environ);
95           }
96         CloseHandle (moreinfo->myself_pinfo);
97         cfree (moreinfo);
98       }
99   }
100 };
101
102 void __stdcall init_child_info (DWORD, child_info *, int, HANDLE);
103
104 extern child_info_fork *child_proc_info;