sigar-test 0.7.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/NOTICE +117 -0
  4. data/README +2 -0
  5. data/Rakefile +105 -0
  6. data/bindings/SigarBuild.pm +301 -0
  7. data/bindings/SigarWrapper.pm +3025 -0
  8. data/bindings/ruby/extconf.rb +131 -0
  9. data/bindings/ruby/rbsigar.c +888 -0
  10. data/include/sigar.h +984 -0
  11. data/include/sigar_fileinfo.h +157 -0
  12. data/include/sigar_format.h +65 -0
  13. data/include/sigar_getline.h +18 -0
  14. data/include/sigar_log.h +80 -0
  15. data/include/sigar_private.h +429 -0
  16. data/include/sigar_ptql.h +53 -0
  17. data/include/sigar_util.h +197 -0
  18. data/src/os/aix/aix_sigar.c +2168 -0
  19. data/src/os/aix/sigar_os.h +73 -0
  20. data/src/os/darwin/Info.plist.in +27 -0
  21. data/src/os/darwin/darwin_sigar.c +3718 -0
  22. data/src/os/darwin/sigar_os.h +80 -0
  23. data/src/os/hpux/hpux_sigar.c +1361 -0
  24. data/src/os/hpux/sigar_os.h +49 -0
  25. data/src/os/linux/linux_sigar.c +2810 -0
  26. data/src/os/linux/sigar_os.h +82 -0
  27. data/src/os/solaris/get_mib2.c +321 -0
  28. data/src/os/solaris/get_mib2.h +127 -0
  29. data/src/os/solaris/kstats.c +181 -0
  30. data/src/os/solaris/procfs.c +97 -0
  31. data/src/os/solaris/sigar_os.h +224 -0
  32. data/src/os/solaris/solaris_sigar.c +2732 -0
  33. data/src/os/win32/peb.c +212 -0
  34. data/src/os/win32/sigar.rc.in +40 -0
  35. data/src/os/win32/sigar_os.h +685 -0
  36. data/src/os/win32/sigar_pdh.h +47 -0
  37. data/src/os/win32/win32_sigar.c +4109 -0
  38. data/src/sigar.c +2444 -0
  39. data/src/sigar_cache.c +253 -0
  40. data/src/sigar_fileinfo.c +815 -0
  41. data/src/sigar_format.c +696 -0
  42. data/src/sigar_getline.c +1849 -0
  43. data/src/sigar_ptql.c +1976 -0
  44. data/src/sigar_signal.c +216 -0
  45. data/src/sigar_util.c +1060 -0
  46. data/src/sigar_version.c.in +22 -0
  47. data/src/sigar_version_autoconf.c.in +22 -0
  48. data/version.properties +11 -0
  49. metadata +91 -0
@@ -0,0 +1,216 @@
1
+ /*
2
+ * Copyright (c) 2007 Hyperic, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #include "sigar.h"
18
+ #include "sigar_private.h"
19
+ #include "sigar_util.h"
20
+
21
+ #ifdef WIN32
22
+ #include <windows.h>
23
+ #endif
24
+
25
+ #include <signal.h>
26
+ #include <errno.h>
27
+
28
+ SIGAR_DECLARE(int) sigar_proc_kill(sigar_pid_t pid, int signum)
29
+ {
30
+ #ifdef WIN32
31
+ int status = -1;
32
+ HANDLE proc =
33
+ OpenProcess(PROCESS_ALL_ACCESS,
34
+ TRUE, (DWORD)pid);
35
+
36
+ if (proc) {
37
+ switch (signum) {
38
+ case 0:
39
+ status = SIGAR_OK;
40
+ break;
41
+ default:
42
+ if (TerminateProcess(proc, signum)) {
43
+ status = SIGAR_OK;
44
+ }
45
+ break;
46
+ }
47
+
48
+ CloseHandle(proc);
49
+
50
+ if (status == SIGAR_OK) {
51
+ return SIGAR_OK;
52
+ }
53
+ }
54
+ return GetLastError();
55
+ #else
56
+ if (kill(pid, signum) == -1) {
57
+ return errno;
58
+ }
59
+ return SIGAR_OK;
60
+ #endif
61
+ }
62
+
63
+ SIGAR_DECLARE(int) sigar_signum_get(char *name)
64
+ {
65
+ if (strnEQ(name, "SIG", 3)) {
66
+ name += 3;
67
+ }
68
+
69
+ switch (*name) {
70
+ case 'A':
71
+ #ifdef SIGABRT
72
+ if (strEQ(name, "ABRT")) return SIGABRT;
73
+ #endif
74
+ #ifdef SIGALRM
75
+ if (strEQ(name, "ALRM")) return SIGALRM;
76
+ #endif
77
+ break;
78
+ case 'B':
79
+ #ifdef SIGBUS
80
+ if (strEQ(name, "BUS")) return SIGBUS;
81
+ #endif
82
+ break;
83
+ case 'C':
84
+ #ifdef SIGCONT
85
+ if (strEQ(name, "CONT")) return SIGCONT;
86
+ #endif
87
+ #ifdef SIGCHLD
88
+ if (strEQ(name, "CHLD")) return SIGCHLD;
89
+ #endif
90
+ #ifdef SIGCLD
91
+ if (strEQ(name, "CLD")) return SIGCLD;
92
+ #endif
93
+ break;
94
+ case 'E':
95
+ #ifdef SIGEMT
96
+ if (strEQ(name, "EMT")) return SIGEMT;
97
+ #endif
98
+ break;
99
+ case 'F':
100
+ #ifdef SIGFPE
101
+ if (strEQ(name, "FPE")) return SIGFPE;
102
+ #endif
103
+ break;
104
+ case 'H':
105
+ #ifdef SIGHUP
106
+ if (strEQ(name, "HUP")) return SIGHUP;
107
+ #endif
108
+ break;
109
+ case 'I':
110
+ #ifdef SIGINT
111
+ if (strEQ(name, "INT")) return SIGINT;
112
+ #endif
113
+ #ifdef SIGILL
114
+ if (strEQ(name, "ILL")) return SIGILL;
115
+ #endif
116
+ #ifdef SIGIOT
117
+ if (strEQ(name, "IOT")) return SIGIOT;
118
+ #endif
119
+ #ifdef SIGIO
120
+ if (strEQ(name, "IO")) return SIGIO;
121
+ #endif
122
+ #ifdef SIGINFO
123
+ if (strEQ(name, "INFO")) return SIGINFO;
124
+ #endif
125
+ break;
126
+ case 'K':
127
+ #ifdef SIGKILL
128
+ if (strEQ(name, "KILL")) return SIGKILL;
129
+ #endif
130
+ break;
131
+ case 'P':
132
+ #ifdef SIGPOLL
133
+ if (strEQ(name, "POLL")) return SIGPOLL;
134
+ #endif
135
+ #ifdef SIGPIPE
136
+ if (strEQ(name, "PIPE")) return SIGPIPE;
137
+ #endif
138
+ #ifdef SIGPROF
139
+ if (strEQ(name, "PROF")) return SIGPROF;
140
+ #endif
141
+ #ifdef SIGPWR
142
+ if (strEQ(name, "PWR")) return SIGPWR;
143
+ #endif
144
+ break;
145
+ case 'Q':
146
+ #ifdef SIGQUIT
147
+ if (strEQ(name, "QUIT")) return SIGQUIT;
148
+ #endif
149
+ break;
150
+ case 'S':
151
+ #ifdef SIGSEGV
152
+ if (strEQ(name, "SEGV")) return SIGSEGV;
153
+ #endif
154
+ #ifdef SIGSYS
155
+ if (strEQ(name, "SYS")) return SIGSYS;
156
+ #endif
157
+ #ifdef SIGSTOP
158
+ if (strEQ(name, "STOP")) return SIGSTOP;
159
+ #endif
160
+ #ifdef SIGSTKFLT
161
+ if (strEQ(name, "STKFLT")) return SIGSTKFLT;
162
+ #endif
163
+ break;
164
+ case 'T':
165
+ #ifdef SIGTRAP
166
+ if (strEQ(name, "TRAP")) return SIGTRAP;
167
+ #endif
168
+ #ifdef SIGTERM
169
+ if (strEQ(name, "TERM")) return SIGTERM;
170
+ #endif
171
+ #ifdef SIGTSTP
172
+ if (strEQ(name, "TSTP")) return SIGTSTP;
173
+ #endif
174
+ #ifdef SIGTTIN
175
+ if (strEQ(name, "TTIN")) return SIGTTIN;
176
+ #endif
177
+ #ifdef SIGTTOU
178
+ if (strEQ(name, "TTOU")) return SIGTTOU;
179
+ #endif
180
+ break;
181
+ case 'U':
182
+ #ifdef SIGURG
183
+ if (strEQ(name, "URG")) return SIGURG;
184
+ #endif
185
+ #ifdef SIGUSR1
186
+ if (strEQ(name, "USR1")) return SIGUSR1;
187
+ #endif
188
+ #ifdef SIGUSR2
189
+ if (strEQ(name, "USR2")) return SIGUSR2;
190
+ #endif
191
+ break;
192
+ case 'V':
193
+ #ifdef SIGVTALRM
194
+ if (strEQ(name, "VTALRM")) return SIGVTALRM;
195
+ #endif
196
+ break;
197
+ case 'W':
198
+ #ifdef SIGWINCH
199
+ if (strEQ(name, "WINCH")) return SIGWINCH;
200
+ #endif
201
+ break;
202
+ case 'X':
203
+ #ifdef SIGXCPU
204
+ if (strEQ(name, "XCPU")) return SIGXCPU;
205
+ #endif
206
+ #ifdef SIGXFSZ
207
+ if (strEQ(name, "XFSZ")) return SIGXFSZ;
208
+ #endif
209
+ break;
210
+ default:
211
+ break;
212
+ }
213
+
214
+ return -1;
215
+ }
216
+