#!/usr/local/bin/wishx -f

proc killProc  {}  {global pid; catch "kill SIGKILL $pid"}

proc startProc {cmd} {
                       global  env pid xtem
                       puts stdout "----- $cmd -----"; flush stdout
                       set pid [eval exec $cmd &]
                       send  $xtem "set p_mkCmd $pid"
                       flush stdout
                     }

signal  trap   SIGHUP  {destroy .}

signal  trap   SIGTERM  {destroy .}

signal  ignore SIGINT

signal  ignore SIGQUIT

signal  trap SIGCHLD  {
    global pid
    if  {![catch  "wait  $pid"]}  then  {
        puts stdout ""; flush stdout
        send  $xtem  {mkCmd_xit}
    }
}

set pid 0

wm withdraw .

set xtem [lindex $argv 0]

send $xtem  set n_mkCmd \"[winfo name .]\"
