DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Creating an SCO Visual Tcl program -- an overview

Completed kill program

##
##
##   Code for Kill Example
##
##

# # Create the menu # proc CreateMenu {form} {

set menubar [VtMenuBar $form.menubar]

set pm [VtPulldown $menubar.processmenu -label "Process"] set vm [VtPulldown $menubar.viewmenu -label "View"]

VtPushButton $pm.killbutton -label "Kill Selected" -callback MenuKillCB VtSeparator $pm.separator VtPushButton $pm.exitbutton -label "Exit" -callback MenuExitCB

VtPushButton $vm.refreshbutton -label "Refresh" -callback MenuRefreshCB }

# # Create the list of processes # proc CreateList {form} { set psList [VtList $form.psList \ -rows 9 \ -columns 25 \ -defaultCallback MenuKillCB] VxSetVar $form list $psList DoRefresh $psList }

# # Callback for Process->Kill # proc MenuKillCB {cbs} { set mainForm [keylget cbs dialog] set psList [VxGetVar $mainForm list] set selProcList [VtListGetSelectedItem $psList -byItemList] set pid [lindex [lindex $selProcList 0] 0]

set form [VtQuestionDialog [keylget cbs dialog].confirm \ -message "Are you sure you want to kill this process?" \ -ok -cancel \ -okCallback "KillCB $pid $mainForm"] VtShow $form }

# # Send command to kill process and refresh list # proc KillCB {pid mainForm cbs} {

catch {exec kill -9 $pid}

set psList [VxGetVar $mainForm list] DoRefresh $psList }

# # Callback for Process->Exit # proc MenuExitCB {cbs} { VtClose exit 0 }

# # Callback for View->Refresh # proc MenuRefreshCB {cbs} { set mainForm [keylget cbs dialog] set psList [VxGetVar $mainForm list] DoRefresh $psList }

# # Put current processes in list # proc DoRefresh {list} { VtListSetItem $list -itemList [GetPsList] }

# # Create the current list of processes for "user" # proc GetPsList {} { set psOut [exec /bin/ps -u [id user] -o pid -o comm] set psOut [split $psOut "\n"] lvarpop psOut return $psOut }

# # Main #

set app [VtOpen Example]

set mainform [VtFormDialog $app.form \ -title "Kill"]

CreateMenu $mainform CreateList $mainform

VtShow $mainform VtMainLoop


Previous topic: Displaying the process list (GetPsList)

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003