(file) Return to ServerProcessVms.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Service

  1 martin 1.3 //%2005////////////////////////////////////////////////////////////////////////
  2 h.sterling 1.1 //
  3 martin     1.3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4                // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5                // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6                // IBM Corp.; EMC Corporation, The Open Group.
  7                // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8                // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9                // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10                // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 h.sterling 1.1 //
 12                // Permission is hereby granted, free of charge, to any person obtaining a copy
 13                // of this software and associated documentation files (the "Software"), to
 14                // deal in the Software without restriction, including without limitation the
 15                // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 16                // sell copies of the Software, and to permit persons to whom the Software is
 17                // furnished to do so, subject to the following conditions:
 18 martin     1.3 //
 19 h.sterling 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20                // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 21                // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 22                // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 23                // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24                // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 25                // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26                // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27                //
 28                //==============================================================================
 29                //
 30                // Author: Sean Keenan (sean.keenan@hp.com)
 31                //
 32                //%/////////////////////////////////////////////////////////////////////////////
 33                
 34                #include <sys/types.h>
 35                #include <sys/stat.h>
 36                #include <fcntl.h>
 37                #include <unistd.h>
 38                #include <Pegasus/Common/Signal.h>
 39                #define MAX_WAIT_TIME 25
 40 h.sterling 1.1 
 41                PEGASUS_USING_PEGASUS;
 42                PEGASUS_USING_STD;
 43                
 44                Boolean handleSigUsr1 = false;
 45                
 46                String newPortNumber = "";
 47                String pegasusTrace  = "";
 48                
 49                
 50                pid_t server_pid;
 51                
 52                void sigUsr1Handler(int s_n, PEGASUS_SIGINFO_T * s_info, void * sig)
 53                {
 54                    handleSigUsr1 = true;
 55                }
 56                
 57                //constructor
 58                ServerProcess::ServerProcess() {}
 59                
 60                //destructor
 61 h.sterling 1.1 ServerProcess::~ServerProcess() {}
 62                
 63                // no-ops
 64                int ServerProcess::cimserver_fork(void) { return 0; }
 65                void ServerProcess::cimserver_set_process(void* p) {}
 66                long ServerProcess::get_server_pid(void) { return 0; }
 67 h.sterling 1.2 void ServerProcess::set_parent_pid(int pid) {}
 68 h.sterling 1.1 int ServerProcess::get_proc(int pid) { return 0; }
 69                void ServerProcess::cimserver_exitRC(int rc) {}
 70                int ServerProcess::cimserver_initialize(void) { return 1; }
 71                int ServerProcess::cimserver_wait(void) { return 1; }
 72                String ServerProcess::getHome(void) { return String::EMPTY; }
 73                
 74                Boolean ServerProcess::isCIMServerRunning(void)
 75                {
 76                  FILE *pid_file;
 77                  pid_t pid = 0;
 78                
 79                  // open the file containing the CIMServer process ID
 80                  pid_file = fopen(getPIDFileName(), "r");
 81                  if (!pid_file)
 82                  {
 83                      return false;
 84                  }
 85                
 86                  // get the pid from the file
 87                  fscanf(pid_file, "%d\n", &pid);
 88                
 89 h.sterling 1.1   fclose(pid_file);
 90                
 91                  if (pid == 0)
 92                  {
 93                     return false;
 94                  }
 95                
 96                  //
 97                  // check to see if cimserver process is alive
 98                  //
 99                  return false;
100                }
101                
102 martin     1.3 int ServerProcess::cimserver_kill(int id)
103                {
104 h.sterling 1.1   FILE *pid_file;
105                  pid_t pid = 0;
106 martin     1.3 
107 h.sterling 1.1   // open the file containing the CIMServer process ID
108                  pid_file = fopen(getPIDFileName(), "r");
109 martin     1.3   if (!pid_file)
110 h.sterling 1.1   {
111                      return (-1);
112                  }
113                
114                  // get the pid from the file
115                  fscanf(pid_file, "%d\n", &pid);
116                
117                  fclose(pid_file);
118                
119                  if (pid == 0)
120                  {
121                     System::removeFile(getPIDFileName());
122                     return (-1);
123                  }
124                
125                  //
126                  // kill the process if it is still alive
127                  //
128                  // remove the file
129                  System::removeFile(getPIDFileName());
130 martin     1.3 
131 h.sterling 1.1   return(0);
132                }
133                // notify parent process to terminate so user knows that cimserver
134                // is ready to serve CIM requests.
135                void ServerProcess::notify_parent(int id)
136                {
137                  pid_t ppid = getppid();
138                  if (id)
139                   kill(ppid, SIGTERM);
140                  else
141 martin     1.3    kill(ppid, PEGASUS_SIGUSR1);
142 h.sterling 1.1 }
143                
144                // Platform specific run
145                int ServerProcess::platform_run( int argc, char** argv, Boolean shutdownOption )
146                {
147                //  newPortNumber = "";
148                //  pegasusTrace = "";
149                  return cimserver_run( argc, argv, shutdownOption );
150                }
151                
152                

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2