(file) Return to cimserver_unix.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / WMIMapper / WMIServer

  1 kumpf 1.1 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3           // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4           // The Open Group, Tivoli Systems
  5           //
  6           // Permission is hereby granted, free of charge, to any person obtaining a copy
  7           // of this software and associated documentation files (the "Software"), to
  8           // deal in the Software without restriction, including without limitation the
  9           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10           // sell copies of the Software, and to permit persons to whom the Software is
 11           // furnished to do so, subject to the following conditions:
 12           // 
 13           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14           // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21           //
 22 kumpf 1.1 //==============================================================================
 23           //
 24           // Author: Mike Day (mdday@us.ibm.com)
 25           //
 26           // Modified By:  Jenny Yu (jenny_yu@hp.com)
 27           //
 28           //%/////////////////////////////////////////////////////////////////////////////
 29           
 30           #include <sys/types.h>
 31           #include <sys/stat.h>
 32           #if defined(PEGASUS_OS_HPUX)
 33           #include <sys/pstat.h>
 34           #endif
 35           #include <fcntl.h>
 36           #include <unistd.h>
 37           
 38           PEGASUS_USING_PEGASUS;
 39           PEGASUS_USING_STD;
 40           
 41           
 42           void cim_server_service(int argc, char **argv ) { return; }  
 43 kumpf 1.1 unsigned int cimserver_remove_nt_service(void) { return(0) ; }
 44           unsigned int cimserver_install_nt_service(String &pegasusHome ) { return(0) ; }
 45           
 46           const char *fname = "/etc/wbem/cimserver_start.conf";
 47           pid_t server_pid;
 48           
 49           // daemon_init , RW Stevens, "Advance UNIX Programming"
 50           
 51           int cimserver_fork(void) 
 52           { 
 53             pid_t pid;
 54             if( (pid = fork() ) < 0) 
 55               return(-1);
 56             else if (pid != 0)
 57               exit(0);
 58             
 59             setsid();
 60             umask(0);
 61           
 62             // get the pid of the cimserver process
 63             server_pid = getpid();
 64 kumpf 1.1 
 65             return(0);
 66           }
 67           
 68           int cimserver_kill(void) 
 69           { 
 70             FILE *pid_file;
 71             pid_t pid = 0;
 72             
 73             // open the file containing the CIMServer process ID
 74             pid_file = fopen(fname, "r");
 75             if (!pid_file) 
 76             {
 77                 return (-1);
 78             }
 79           
 80             // get the pid from the file
 81             fscanf(pid_file, "%ld\n", &pid);
 82           
 83             if (pid == 0)
 84             {
 85 kumpf 1.1      System::removeFile(fname);
 86                return (-1);
 87             }
 88           
 89             //
 90             // kill the process if it is still alive
 91             //
 92           #if defined(PEGASUS_OS_HPUX)
 93             struct pst_status pstru;
 94           
 95             if (pstat_getproc(&pstru, sizeof(struct pst_status), (size_t)0, pid) != -1)
 96             {
 97                 kill(pid, SIGKILL);
 98             }
 99           #endif
100           
101             // remove the file
102             System::removeFile(fname);
103             
104             return(0);
105           }
106 kumpf 1.1 

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2