How do you get the process and thread name from within a tcl proc? I want to modify the resend recovery proc so that if after “3” resends, to stop and start the thread; then proto the $ob_save.
The thread name is in the HciConnName variable, which you need to make global at the beginning of your proc:
Code:
global HciConnName
The process name I am not sure of, but we have a TCL proc we wrote in which if given the thread name returns its process name. There may be something easier for this, but this works.
Code:
######################################################################
# get_pname – get the process name that contains the specified thread
#
# Args: thread = the thread name
#
# Returns: process = the process that contains the specified thd
#
proc get_pname { thread } {
set conndata [exec hciconndump $thread]
set lines [split $conndata n]
set thdinfo [lindex $lines 3]
set pname [lindex $thdinfo 0]
if {”$pname” == “”} {error “Thread not found: $thread”}
return $pname
}
pwd is current directory. The file tail command returns the last component of the path. Since a Cloverleaf engine always runs in the process directory which is the sma name of the process, you have the process name