|
1 |
| -/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.65 2007/01/11 02:42:31 momjian Exp $ */ |
| 1 | +/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.66 2007/01/22 18:31:51 momjian Exp $ */ |
2 | 2 |
|
3 | 3 | #if defined(_MSC_VER) || defined(__BORLANDC__)
|
4 | 4 | #define WIN32_ONLY_COMPILER
|
@@ -115,16 +115,38 @@ int semop(int semId, struct sembuf * sops, int flag);
|
115 | 115 |
|
116 | 116 | /*
|
117 | 117 | * Signal stuff
|
118 |
| - * WIN32 doesn't have wait(), so the return value for children |
119 |
| - * is simply the return value specified by the child, without |
120 |
| - * any additional information on whether the child terminated |
121 |
| - * on its own or via a signal. These macros are also used |
122 |
| - * to interpret the return value of system(). |
| 118 | + * |
| 119 | + * For WIN32, there is no wait() call so there are no wait() macros |
| 120 | + * to interpret the return value of system(). Instead, system() |
| 121 | + * return values < 0x100 are used for exit() termination, and higher |
| 122 | + * values are used to indicated non-exit() termination, which is |
| 123 | + * similar to a unix-style signal exit (think SIGSEGV == |
| 124 | + * STATUS_ACCESS_VIOLATION). Return values are broken up into groups: |
| 125 | + * |
| 126 | + * http://msdn2.microsoft.com/en-gb/library/aa489609.aspx |
| 127 | + * |
| 128 | + * NT_SUCCESS 0 - 0x3FFFFFFF |
| 129 | + * NT_INFORMATION 0x40000000 - 0x7FFFFFFF |
| 130 | + * NT_WARNING 0x80000000 - 0xBFFFFFFF |
| 131 | + * NT_ERROR 0xC0000000 - 0xFFFFFFFF |
| 132 | + * |
| 133 | + * Effectively, we don't care on the severity of the return value from |
| 134 | + * system(), we just need to know if it was because of exit() or generated |
| 135 | + * by the system, and it seems values >= 0x100 are system-generated. |
| 136 | + * See this URL for a list of WIN32 STATUS_* values: |
| 137 | + * |
| 138 | + * Wine (URL used in our error messages) - |
| 139 | + * http://source.winehq.org/source/include/ntstatus.h |
| 140 | + * Descriptions - http://www.comp.nus.edu.sg/~wuyongzh/my_doc/ntstatus.txt |
| 141 | + * MS SDK - http://www.nologs.com/ntstatus.html |
| 142 | + * |
| 143 | + * Some day we might want to print descriptions for the most common |
| 144 | + * exceptions, rather than printing a URL. |
123 | 145 | */
|
124 |
| -#define WEXITSTATUS(w) (w) |
125 |
| -#define WIFEXITED(w) (true) |
126 |
| -#define WIFSIGNALED(w) (false) |
127 |
| -#define WTERMSIG(w) (0) |
| 146 | +#define WIFEXITED(w) (((w) & 0xffffff00) == 0) |
| 147 | +#define WIFSIGNALED(w) (!WIFEXITED(w)) |
| 148 | +#define WEXITSTATUS(w) (w) |
| 149 | +#define WTERMSIG(w) (w) |
128 | 150 |
|
129 | 151 | #define sigmask(sig) ( 1 << ((sig)-1) )
|
130 | 152 |
|
|
0 commit comments