version 1.3, 2007/05/30 20:41:27
|
version 1.4, 2007/06/12 18:19:46
|
|
|
/* | /* |
**============================================================================== | **============================================================================== |
** | ** |
** ReadPidFile() |
|
** |
|
**============================================================================== |
|
*/ |
|
|
|
static int ReadPidFile(const char* path, int* pid) |
|
{ |
|
FILE* is = fopen(path, "r"); |
|
|
|
if (!is) |
|
return -1; |
|
|
|
*pid = 0; |
|
|
|
fscanf(is, "%d\n", pid); |
|
fclose(is); |
|
|
|
if (*pid == 0) |
|
return -1; |
|
|
|
return 0; |
|
} |
|
|
|
/* |
|
**============================================================================== |
|
** |
|
** TestCimServerProcess() |
|
** |
|
** Returns 0 if cimserver process is running. |
|
** |
|
**============================================================================== |
|
*/ |
|
|
|
int TestCimServerProcess() |
|
{ |
|
int pid; |
|
char name[EXECUTOR_BUFFER_SIZE]; |
|
|
|
if (ReadPidFile(PEGASUS_CIMSERVER_START_FILE, &pid) != 0) |
|
return -1; |
|
|
|
if (GetProcessName(pid, name) != 0 || strcmp(name, CIMSERVERMAIN) != 0) |
|
return -1; |
|
|
|
return 0; |
|
} |
|
|
|
/* |
|
**============================================================================== |
|
** |
|
** ExecShutdown() | ** ExecShutdown() |
** | ** |
**============================================================================== | **============================================================================== |
|
|
| |
if (options.dump) | if (options.dump) |
{ | { |
DumpPolicy(1); |
DumpPolicy(stdout, 1); |
DumpMacros(); |
DumpMacros(stdout); |
exit(0); | exit(0); |
} | } |
| |
|
|
* passed through to CIMSERVERMAIN). | * passed through to CIMSERVERMAIN). |
*/ | */ |
| |
if (!options.version && !options.help && TestCimServerProcess() == 0) |
if (!options.version && |
|
!options.help && |
|
TestProcessRunning(PEGASUS_CIMSERVER_START_FILE, CIMSERVERMAIN) == 0) |
{ | { |
fprintf(stderr, | fprintf(stderr, |
"%s: cimserver is already running (the PID found in the file " | "%s: cimserver is already running (the PID found in the file " |
|
|
| |
CloseOnExec(pair[1]); | CloseOnExec(pair[1]); |
| |
/* Get the log-level from the configuration parameter. */ |
/* Initialize the log-level from the configuration parameter. */ |
| |
GetLogLevel(argc, argv); |
InitLogLevel(); |
| |
/* Open the log. */ | /* Open the log. */ |
| |