* windows.h prior to any other Apache header files.
*/
-#ifndef _WIN32
-#define _WIN32
+#ifndef ap_os_h
+#define ap_os_h
#endif
#include <io.h>
#include <stddef.h>
-#endif /* ! APACHE_OS_H */
+/* BIG RED WARNING: exit() is mapped to allow us to capture the exit
+ * status. This header must only be included from modules linked into
+ * the ApacheCore.dll - since it's a horrible behavior to exit() from
+ * any module outside the main() block, and we -will- assume it's a
+ * fatal error. No dynamically linked module will ever be able to find
+ * the real_exit_code, and _will_ GP fault if it tries this macro.
+ */
+
+AP_DECLARE_DATA extern int real_exit_code;
+
+#define exit(status) ((exit)((real_exit_code==2) ? (real_exit_code = (status)) \
+ : ((real_exit_code = 0), (status))))
+
+#endif /* ! ap_os_h */
my_pid = GetCurrentProcessId();
parent_pid = (DWORD) atol(pid);
+ /* Prevent holding open the (nonexistant) console */
+ real_exit_code = 0;
+
/* The parent is responsible for providing the
* COMPLETE ARGUMENTS REQUIRED to the child.
*
optbuf[2] = '\0';
apr_getopt_init(&opt, process->pool, process->argc, (char**) process->argv);
opt->errfn = NULL;
- while ((rv = apr_getopt(opt, "n:k:iu" AP_SERVER_BASEARGS,
+ while ((rv = apr_getopt(opt, "wn:k:" AP_SERVER_BASEARGS,
optbuf + 1, &optarg)) == APR_SUCCESS) {
switch (optbuf[1]) {
+
+ /* Shortcuts; include the -w option to hold the window open on error.
+ * This must not be toggled once we reset real_exit_code to 0!
+ */
+ case 'w':
+ if (real_exit_code)
+ real_exit_code = 2;
+ break;
+
case 'n':
service_set = mpm_service_set_name(process->pool, &service_name,
optarg);
break;
+
case 'k':
signal_arg = optarg;
break;
+
case 'E':
errout = 1;
/* Fall through so the Apache main() handles the 'E' arg */
/* Initialize shared static objects.
*/
pconf = pconf_;
-
+
+ /* This behavior is voided by setting real_exit_code to 0 */
+ atexit(hold_console_open_on_error);
+
if (ap_exists_config_define("ONE_PROCESS") ||
ap_exists_config_define("DEBUG"))
one_process = -1;
AP_DECLARE(PCOMP_CONTEXT) mpm_get_completion_context(void);
AP_DECLARE(void) mpm_recycle_completion_context(PCOMP_CONTEXT pCompContext);
AP_DECLARE(apr_status_t) mpm_post_completion_context(PCOMP_CONTEXT pCompContext, io_state_e state);
+void hold_console_open_on_error(void);
#endif /* APACHE_MPM_WINNT_H */
* behavior on exit. All service and child processes are expected to
* reset this flag to zero to avoid undesireable side effects.
*/
-int real_exit_code = 1;
+AP_DECLARE_DATA int real_exit_code = 1;
void hold_console_open_on_error(void)
{
HANDLE hThread = GetCurrentThread();
HANDLE waitfor[2];
+ /* Prevent holding open the (hidden) console */
+ real_exit_code = 0;
+
/* GetCurrentThread returns a psuedo-handle, we need
* a real handle for another thread to wait upon.
*/