1 2# 3# This bit of code is mainly to overcome the need for TclX which is not 4# in the freewrap code. This for those who use the fr.exe version of fr. 5# 6# The missing piece is a function to kill a process by pid. With no function 7# we must use a program. Over the years MS has shipped various kill 8# programs. Hopefully we have yours in the list. 9# 10# We will use the TclX call: 11# 12# kill ?signal? idlist (note we do NOT handle -pgroup, or rather we 13# ignor it.) 14# 15# The first thing one should do is call the killInit routine below. 16# It will set up the proper kill call 17 18proc killInit {} { 19 set killProcs [list \ 20 {kill.exe /f %s} \ 21 {kill -s 9 %s} \ 22 {pskill.exe -t %s}\ 23 {tskill.exe %s } \ 24 {taskkill.exe /f /pid %s /t}\ 25 ] 26 27 28 # the prefered way... 29 if {[info command kill] != {}} {return} 30 set r [catch {package require Tclx}] 31 if {$r == 0} {return 0} 32 33 # Ok, we don't have the kill command. 34 foreach p $killProcs { 35 set full [auto_execok [lindex $p 0]] 36 if {$full != {}} { 37 frputs "building with $full " 38 set body [format { 39 foreach pid $args { 40 if { [string index $pid 0] == "-"} {continue} 41 exec %s 42 } 43 } [format [lreplace $p 0 0 $full] \$pid]] 44 # puts "body is $body" 45 proc kill args $body 46 return {} 47 } 48 } 49 puts "no kill program found" 50 proc kill args {error "No kill function or program found."} 51 return $killProcs 52} 53