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