Originally posted by Anonymous
Loads of times you want to know the process id of running processes. This id is stored in the pid file of the process in its process directory. What sounds more logic than to display the contents of this file with the hciprocstatus output?
Luckily the hciprocstatus command is TCL so so you simply add a little to it in the procedure emitSummary. This is the procedure after change:
proc emitSummary { data } {
global HciProcessesDir ExitStatus
set ExitStatus 0
# added %-5.5s to end of output that will hold the pid
set fmt "%-15.15s %-8.8s %-48.48s %-5.5s"
echo [format $fmt Process State Message Pid]
echo "--------------- -------- ------------------------------------------------ -----"
foreach entry $data {
lassign $entry process state msg
# The pid file might not exist. Display empty if so
set pidFile [file join $HciProcessesDir $process pid]
if { [file readable $pidFile] } {
regsub -all -- {[^0-9]} [read_file $pidFile] "" ppid
} else {
set ppid ""
}
echo [format $fmt $process $state $msg $ppid]
if { $state == "running" } {
set ExitStatus 1
}
}
}For those that don't want to edit $HCIROOT/bin/hciprocstatus, I have attached the edited resulted for 5.4P. As far as know the hciprocstatus command has not changed since 3.3.0P, but: Create a backup, or better yet copy the command somewhere else to try it out first.
Sample output:
Process State Message Pid
--------------- -------- ------------------------------------------------ -----
HTB4DEV_3 dead Exit time unavailable
HTB5DEV_4_1 running Started at Tue Apr 04 09:26:24 2006 1772
The attached has the extension htc for Windows. For UNIX just remove that and edit the interpreter line at the top.