1 h.sterling 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 h.sterling 1.1 //==============================================================================
23 //
24 // Author: Sean Keenan (sean.keenan@hp.com)
25 //
26 //%/////////////////////////////////////////////////////////////////////////////
27
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <fcntl.h>
31 #include <unistd.h>
32 #include <Pegasus/Common/Signal.h>
33 #define MAX_WAIT_TIME 25
34
35 PEGASUS_USING_PEGASUS;
36 PEGASUS_USING_STD;
37
38 Boolean handleSigUsr1 = false;
39
40 String newPortNumber = "";
41 String pegasusTrace = "";
42
43 h.sterling 1.1
44 pid_t server_pid;
45
46 void sigUsr1Handler(int s_n, PEGASUS_SIGINFO_T * s_info, void * sig)
47 {
48 handleSigUsr1 = true;
49 }
50
51 //constructor
52 ServerProcess::ServerProcess() {}
53
54 //destructor
55 ServerProcess::~ServerProcess() {}
56
57 // no-ops
58 int ServerProcess::cimserver_fork(void) { return 0; }
59 void ServerProcess::cimserver_set_process(void* p) {}
60 long ServerProcess::get_server_pid(void) { return 0; }
61 int ServerProcess::get_proc(int pid) { return 0; }
62 void ServerProcess::cimserver_exitRC(int rc) {}
63 int ServerProcess::cimserver_initialize(void) { return 1; }
64 h.sterling 1.1 int ServerProcess::cimserver_wait(void) { return 1; }
65 String ServerProcess::getHome(void) { return String::EMPTY; }
66
67 Boolean ServerProcess::isCIMServerRunning(void)
68 {
69 FILE *pid_file;
70 pid_t pid = 0;
71
72 // open the file containing the CIMServer process ID
73 pid_file = fopen(getPIDFileName(), "r");
74 if (!pid_file)
75 {
76 return false;
77 }
78
79 // get the pid from the file
80 fscanf(pid_file, "%d\n", &pid);
81
82 fclose(pid_file);
83
84 if (pid == 0)
85 h.sterling 1.1 {
86 return false;
87 }
88
89 //
90 // check to see if cimserver process is alive
91 //
92 return false;
93 }
94
95 int ServerProcess::cimserver_kill(int id)
96 {
97 FILE *pid_file;
98 pid_t pid = 0;
99
100 // open the file containing the CIMServer process ID
101 pid_file = fopen(getPIDFileName(), "r");
102 if (!pid_file)
103 {
104 return (-1);
105 }
106 h.sterling 1.1
107 // get the pid from the file
108 fscanf(pid_file, "%d\n", &pid);
109
110 fclose(pid_file);
111
112 if (pid == 0)
113 {
114 System::removeFile(getPIDFileName());
115 return (-1);
116 }
117
118 //
119 // kill the process if it is still alive
120 //
121 // remove the file
122 System::removeFile(getPIDFileName());
123
124 return(0);
125 }
126 // notify parent process to terminate so user knows that cimserver
127 h.sterling 1.1 // is ready to serve CIM requests.
128 void ServerProcess::notify_parent(int id)
129 {
130 pid_t ppid = getppid();
131 if (id)
132 kill(ppid, SIGTERM);
133 else
134 kill(ppid, PEGASUS_SIGUSR1);
135 }
136
137 // Platform specific run
138 int ServerProcess::platform_run( int argc, char** argv, Boolean shutdownOption )
139 {
140 // newPortNumber = "";
141 // pegasusTrace = "";
142 return cimserver_run( argc, argv, shutdownOption );
143 }
144
145
|