/*
process.c -- process management functions
Copyright (C) 1999-2005 Ivo Timmermans,
/*
process.c -- process management functions
Copyright (C) 1999-2005 Ivo Timmermans,
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
strncat(command, "\"", sizeof command - strlen(command));
for(char **argp = g_argv + 1; *argp; argp++) {
strncat(command, "\"", sizeof command - strlen(command));
for(char **argp = g_argv + 1; *argp; argp++) {
service = CreateService(manager, identname, identname,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
command, NULL, NULL, NULL, NULL, NULL);
service = CreateService(manager, identname, identname,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
command, NULL, NULL, NULL, NULL, NULL);
if(!service) {
DWORD lasterror = GetLastError();
logger(DEBUG_ALWAYS, LOG_ERR, "Could not create %s service: %s", identname, winerror(lasterror));
if(!service) {
DWORD lasterror = GetLastError();
logger(DEBUG_ALWAYS, LOG_ERR, "Could not create %s service: %s", identname, winerror(lasterror));
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_SHUTDOWN");
break;
default:
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_SHUTDOWN");
break;
default:
- logger(DEBUG_ALWAYS, LOG_WARNING, "Got unexpected request %d", request);
+ logger(DEBUG_ALWAYS, LOG_WARNING, "Got unexpected request %d", (int)request);
SetServiceStatus(statushandle, &status);
return NO_ERROR;
}
VOID WINAPI run_service(DWORD argc, LPTSTR* argv) {
SetServiceStatus(statushandle, &status);
return NO_ERROR;
}
VOID WINAPI run_service(DWORD argc, LPTSTR* argv) {
- status.dwWin32ExitCode = 0;
- status.dwServiceSpecificExitCode = 0;
- status.dwCheckPoint = 0;
+ status.dwWin32ExitCode = 0;
+ status.dwServiceSpecificExitCode = 0;
+ status.dwCheckPoint = 0;
if (!statushandle) {
logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "RegisterServiceCtrlHandlerEx", winerror(GetLastError()));
if (!statushandle) {
logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "RegisterServiceCtrlHandlerEx", winerror(GetLastError()));
status.dwCurrentState = SERVICE_RUNNING;
SetServiceStatus(statushandle, &status);
status.dwCurrentState = SERVICE_RUNNING;
SetServiceStatus(statushandle, &status);
- fprintf(stderr, "Couldn't detach from terminal: %s",
- strerror(errno));
+ logger(DEBUG_ALWAYS, LOG_ERR, "Couldn't detach from terminal: %s", strerror(errno));
if(WEXITSTATUS(status)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s exited with non-zero status %d",
name, WEXITSTATUS(status));
return false;
}
if(WEXITSTATUS(status)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s exited with non-zero status %d",
name, WEXITSTATUS(status));
return false;
}
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s was killed by signal %d (%s)",
name, WTERMSIG(status), strsignal(WTERMSIG(status)));
return false;
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s was killed by signal %d (%s)",
name, WTERMSIG(status), strsignal(WTERMSIG(status)));
return false;
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s terminated abnormally", name);
return false;
}
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s terminated abnormally", name);
return false;
}