3 carson.hovey 1.2 // 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 gs.keenan 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 //
19 // 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 gs.keenan 1.1 //%/////////////////////////////////////////////////////////////////////////////
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
41 PEGASUS_USING_PEGASUS;
42 PEGASUS_USING_STD;
43
44 Boolean handleSigUsr1 = false;
45
46 String newPortNumber = "";
47 String pegasusTrace = "";
48
49 void cim_server_service(int argc, char **argv )
50 {
51 return;
52 }
53 gs.keenan 1.1
54 pid_t server_pid;
55
56 void sigUsr1Handler(int s_n, PEGASUS_SIGINFO_T * s_info, void * sig)
57 {
58 handleSigUsr1 = true;
59 }
60
61 int cimserver_fork(void)
62 {
63 return(0);
64 }
65
66 Boolean isCIMServerRunning(void)
67 {
68 FILE *pid_file;
69 pid_t pid = 0;
70
71 // open the file containing the CIMServer process ID
72 pid_file = fopen(CIMSERVER_START_FILE, "r");
73 if (!pid_file)
74 gs.keenan 1.1 {
75 return false;
76 }
77
78 // get the pid from the file
79 fscanf(pid_file, "%d\n", &pid);
80
81 fclose(pid_file);
82
83 if (pid == 0)
84 {
85 return false;
86 }
87
88 //
89 // check to see if cimserver process is alive
90 //
91 return false;
92 }
93
94 int cimserver_kill(void)
95 gs.keenan 1.1 {
96 FILE *pid_file;
97 pid_t pid = 0;
98
99 // open the file containing the CIMServer process ID
100 pid_file = fopen(CIMSERVER_START_FILE, "r");
101 if (!pid_file)
102 {
103 return (-1);
104 }
105
106 // get the pid from the file
107 fscanf(pid_file, "%d\n", &pid);
108
109 fclose(pid_file);
110
111 if (pid == 0)
112 {
113 System::removeFile(CIMSERVER_START_FILE);
114 return (-1);
115 }
116 gs.keenan 1.1
117 //
118 // kill the process if it is still alive
119 //
120 // remove the file
121 System::removeFile(CIMSERVER_START_FILE);
122
123 return(0);
124 }
125 // notify parent process to terminate so user knows that cimserver
126 // is ready to serve CIM requests.
127 void notify_parent(int id)
128 {
129 pid_t ppid = getppid();
130 if (id)
131 kill(ppid, SIGTERM);
132 else
133 kill(ppid, PEGASUS_SIGUSR1);
134 }
135
136 // Platform specific run
137 gs.keenan 1.1 int platform_run( int argc, char** argv, Boolean shutdownOption )
138 {
139 // newPortNumber = "";
140 // pegasusTrace = "";
141 return cimserver_run( argc, argv, shutdownOption );
142 }
143
144 void cimserver_set( CIMServer* s )
145 {
146 }
147
|