Author: mladen.turk(a)jboss.com
Date: 2012-12-20 01:14:10 -0500 (Thu, 20 Dec 2012)
New Revision: 2975
Modified:
trunk/utils/windows/native/service/jbosssvc/jboss.c
Log:
Wait on event instead of process
Modified: trunk/utils/windows/native/service/jbosssvc/jboss.c
===================================================================
--- trunk/utils/windows/native/service/jbosssvc/jboss.c 2012-12-18 06:17:26 UTC (rev
2974)
+++ trunk/utils/windows/native/service/jbosssvc/jboss.c 2012-12-20 06:14:10 UTC (rev
2975)
@@ -277,8 +277,8 @@
fprintf(stderr, "jbosssvc -- program for running batch files as
services.\n\n");
fprintf(stderr, "Usage: jbosssvc -i service service.bat\n");
- fprintf(stderr, " -i[wdcl] service workingpath description
comment\n"
- " service.bat\n");
+ fprintf(stderr, " -i[wdclz] service workingpath description
comment\n"
+ " timeout service.bat\n");
fprintf(stderr, " -u service\n");
fprintf(stderr, " -t service\n");
fprintf(stderr, " -s\n");
@@ -299,14 +299,14 @@
if (_service_mode == mode_run)
return;
- fprintf(stdout, "Name %s\n", _service_name);
- fprintf(stdout, "Display %s\n", _service_disp);
- fprintf(stdout, "Description %s\n", _service_desc);
- fprintf(stdout, "ImagePath %s\n", _service_image);
- fprintf(stdout, "Shell %s\n", _cmd_exe);
- fprintf(stdout, "WorkingPath %s\n", _working_path);
- fprintf(stdout, "Service Script %s\n", _service_bat);
-
+ fprintf(stdout, "Name : %s\n", _service_name);
+ fprintf(stdout, "Display : %s\n", _service_disp);
+ fprintf(stdout, "Description : %s\n", _service_desc);
+ fprintf(stdout, "ImagePath : %s\n", _service_image);
+ fprintf(stdout, "Shell : %s\n", _cmd_exe);
+ fprintf(stdout, "WorkingPath : %s\n", _working_path);
+ fprintf(stdout, "Service Script : %s\n", _service_bat);
+ fprintf(stdout, "Shutdown Timeout : %d\n", _service_shtm);
}
static BOOL IsServiceRunning(LPCSTR szServiceName)
@@ -539,8 +539,8 @@
BOOL InstallService(LPCSTR szServiceName)
{
- char szImage[MAX_PATH + 1];
- char szPath[MAX_PATH + 1];
+ char szImage[MAX_PATH + 2];
+ char szPath[MAX_PATH + 2];
char *p;
BOOL rv = TRUE;
SC_HANDLE hManager;
@@ -703,13 +703,11 @@
} while (Process32Next(hProcessSnap, &pe32));
CloseHandle(hProcessSnap);
- Sleep(500);
- if (_service_run_hproc != NULL) {
- if (WaitForSingleObject(_service_run_hproc, 500) == WAIT_TIMEOUT)
+ if (WaitForSingleObject(_service_run_event, 2000) == WAIT_TIMEOUT) {
+ if (_service_run_hproc != NULL)
return TerminateProcess(_service_run_hproc, retCode);
}
return TRUE;
-
}
/* Executed when the service receives stop event */