1 mike 1.5 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.8 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 kumpf 1.8 // 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 mike 1.5 // 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 kumpf 1.8 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
14 mike 1.5 // 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 kumpf 1.8 // 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 mike 1.5 // 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 //==============================================================================
23 //
24 // Author: Mike Day (mdday@us.ibm.com)
25 //
|
26 kumpf 1.6 // Modified By: Jenny Yu (jenny_yu@hp.com)
|
27 mike 1.5 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
30 #include <sys/types.h>
31 #include <sys/stat.h>
|
32 kumpf 1.7 #if defined(PEGASUS_OS_HPUX)
|
33 kumpf 1.6 #include <sys/pstat.h>
|
34 kumpf 1.7 #endif
|
35 mike 1.5 #include <fcntl.h>
36 #include <unistd.h>
37
38 PEGASUS_USING_PEGASUS;
39 PEGASUS_USING_STD;
40
|
41 kumpf 1.6
|
42 mike 1.5 void cim_server_service(int argc, char **argv ) { return; }
43 unsigned int cimserver_remove_nt_service(void) { return(0) ; }
44 unsigned int cimserver_install_nt_service(String &pegasusHome ) { return(0) ; }
45
|
46 kumpf 1.6 const char *fname = "/etc/wbem/cimserver_start.conf";
47 pid_t server_pid;
48
|
49 mike 1.5 // 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 kumpf 1.6
62 // get the pid of the cimserver process
63 server_pid = getpid();
64
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 kumpf 1.6
83 if (pid == 0)
84 {
85 System::removeFile(fname);
86 return (-1);
87 }
88
89 //
90 // kill the process if it is still alive
91 //
|
92 kumpf 1.7 #if defined(PEGASUS_OS_HPUX)
|
93 kumpf 1.6 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 kumpf 1.7 #endif
|
100 kumpf 1.6
101 // remove the file
102 System::removeFile(fname);
103
|
104 mike 1.5 return(0);
105 }
106
|