- Timestamp:
- 06/22/2001 09:00:46 PM (23 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 6.0, 6.1, 6.1.1, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, v3_0, v3_1, v3_2, v3_3, v4_0, v4_1, v5_0, v5_1, v5_1_1, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- e87f37a9
- Parents:
- 4e90962
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/functions.xml
r4e90962 rf45bf82 21 21 22 22 COL=70 23 WCOL=50 23 24 SET_COL="echo -en \\033[${COL}G" 25 SET_WCOL="echo -en \\033[${WCOL}G" 24 26 NORMAL="echo -en \\033[0;39m" 25 27 SUCCESS="echo -en \\033[1;32m" 28 WARNING="echo -en \\033[1;33m" 26 29 FAILURE="echo -en \\033[1;31m" 27 30 … … 73 76 $NORMAL 74 77 echo " ]" 78 ;; 79 warning) 80 $SET_COL 81 echo -n "[ " 82 $WARNING 83 echo -n "ATTN" 84 $NORMAL 85 echo " ]" 75 86 ;; 76 87 failure) … … 141 152 # return value 142 153 # 154 143 155 $* 144 156 evaluate_retval 145 157 else 146 158 # 147 # The variable $pid was not empty, meaning it was already running. We 148 # print [FAILED] now 149 # 150 print_status failure 159 # The variable $pid was not empty, meaning it was already running. We'll 160 # print [ ATTN ] now 161 # 162 163 $SET_WCOL 164 echo -n "Already running" 165 print_status warning 151 166 fi 152 167 … … 216 231 # more PID's were found that belongs to the processes to be killed 217 232 # 233 218 234 if [ -n "$pid" ] 219 235 then 236 220 237 # 221 238 # If no kill level was specified we'll try -TERM first and then sleep 222 239 # for 2 seconds to allow the kill to be completed 223 240 # 241 224 242 if [ "$nolevel" = 1 ] 225 243 then 226 244 /bin/kill -TERM $pid 245 227 246 # 228 247 # If after -TERM the PID still exists we'll wait 2 seconds before … … 251 270 # and we'll print [FAILED] 252 271 # 272 253 273 print_status failure 254 274 else 275 255 276 # 256 277 # It was killed, remove possible stale PID file in /var/run and 257 278 # print [ OK ] 258 279 # 280 259 281 /bin/rm -f /var/run/$base.pid 260 282 print_status success 261 283 fi 262 284 else 285 263 286 # 264 287 # A kill level was provided. Kill with the provided kill level and wait 265 288 # for 2 seconds to allow the kill to be completed 266 289 # 290 267 291 /bin/kill $killlevel $pid 268 292 if /bin/ps h $pid > /dev/null 2>&1 … … 273 297 if [ $? = 0 ] 274 298 then 299 275 300 # 276 301 # If ps' return value is 0 it means it ran ok which indicates that the … … 278 303 # the signal provided. Print [FAILED] 279 304 # 305 280 306 print_status failure 281 307 else 308 282 309 # 283 310 # If the return value was 1 or higher it means the PID didn't exist … … 285 312 # PID file and print [ OK ] 286 313 # 314 287 315 /bin/rm -f /var/run/$base.pid 288 316 print_status success … … 290 318 fi 291 319 else 292 # 293 # The PID didn't exist so we can't attempt to kill it. Print [FAILED] 294 # 295 print_status failure 320 321 # 322 # The PID didn't exist so we can't attempt to kill it. Print [ ATTN ] 323 # 324 325 $SET_WCOL 326 echo -n "Not running" 327 print_status warning 296 328 fi 297 329 } … … 333 365 # 334 366 335 336 367 if [ -n "$2" ] 337 368 then … … 376 407 evaluate_retval 377 408 else 409 378 410 # 379 411 # Else we will use the provided signal … … 384 416 fi 385 417 else 386 # 387 # If $pid is empty no PID's have been found that belong to the process 388 # and print [FAILED] 389 # 390 391 print_status failure 418 419 # 420 # If $pid is empty no PID's have been found that belong to the process. 421 # Print [ ATTN ] 422 # 423 424 $SET_WCOL 425 echo -n "Not running" 426 print_status warning 392 427 fi 393 428 } … … 419 454 if [ -n "$pid" ] 420 455 then 456 421 457 # 422 458 # If $pid contains something, the process is running, print the contents 423 459 # of the $pid variable 424 460 # 461 425 462 echo "$1 running with Process ID $pid" 426 463 return 0
Note:
See TracChangeset
for help on using the changeset viewer.