int ServerProcess::cimserver_kill(int id) { FILE *pid_file; pid_t pid = 0; // open the file containing the CIMServer process ID pid_file = fopen(getPIDFileName(), "r"); if (!pid_file) { return (-1); } // get the pid from the file fscanf(pid_file, "%d\n", &pid); fclose(pid_file); if (pid == 0) { System::removeFile(getPIDFileName()); return (-1); } // // kill the process if it is still alive // // remove the file System::removeFile(getPIDFileName()); return(0); }
int ServerProcess::cimserver_kill(int id) { FILE *pid_file; pid_t pid = 0; // open the file containing the CIMServer process ID pid_file = fopen(getPIDFileName(), "r"); if (!pid_file) { return (-1); } // get the pid from the file fscanf(pid_file, "%d\n", &pid); fclose(pid_file); if (pid == 0) { System::removeFile(getPIDFileName()); return (-1); } // // kill the process if it is still alive // #if defined(PEGASUS_OS_HPUX) struct pst_status pstru; int ret_code; ret_code = pstat_getproc(&pstru, sizeof(struct pst_status), (size_t)0, pid); if ( (ret_code != -1 ) && (strcmp(pstru.pst_ucomm, getProcessName())) == 0) { // cimserver is running, kill the process kill(pid, SIGKILL); } #endif #if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC) if (get_proc(pid) != -1 ) { kill(pid, SIGKILL); } #endif #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) if (isProcRunning(pid)) { kill(pid, SIGKILL); } #endif #if defined(PEGASUS_OS_AIX) if (!aixcimsrvrunning(pid, getProcessName())) kill(pid,SIGKILL); #endif // remove the file System::removeFile(getPIDFileName()); return(0); }
Boolean ServerProcess::isCIMServerRunning(void) { FILE *pid_file; pid_t pid = 0; // open the file containing the CIMServer process ID pid_file = fopen(getPIDFileName(), "r"); if (!pid_file) { return false; } // get the pid from the file fscanf(pid_file, "%d\n", &pid); fclose(pid_file); if (pid == 0) { return false; } // // check to see if cimserver process is alive // return false; }
Boolean ServerProcess::isCIMServerRunning(void) { FILE *pid_file; pid_t pid = 0; // open the file containing the CIMServer process ID pid_file = fopen(getPIDFileName(), "r"); if (!pid_file) { return false; } // get the pid from the file fscanf(pid_file, "%d\n", &pid); fclose(pid_file); if (pid == 0) { return false; } // // check to see if cimserver process is alive // #if defined(PEGASUS_OS_HPUX) struct pst_status pstru; int ret_code; ret_code = pstat_getproc(&pstru, sizeof(struct pst_status), (size_t)0, pid); if ( (ret_code != -1 ) && (strcmp(pstru.pst_ucomm, getProcessName())) == 0) { // // Check to see if this command process has the same pid as the // cimserver daemon process pid stored in the cimserver_start.conf // file. Since the command has the same name as the cimserver daemon // process, this could happen after a system reboot. If the pids are // the same, cimserver isn't really running. // Uint32 mypid = System::getPID(); if ((mypid != pid) && (parentPid != pid)) { // cimserver is running return true; } } #endif #if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC) if (get_proc(pid) != -1 ) { // cimserver is running return true; } #endif #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) return isProcRunning(pid); #endif #if defined(PEGASUS_OS_AIX) if (aixcimsrvrunning(pid, getProcessName())!=-1) return true; #endif return false; }