# mkcmd_wait executes the command given by parameter "cmd" in procedure "startProc"
#
# is called from mkcommand.4/mkCmd_wait: 
# "... exec $xtermcall  -e $wishcall       -f $xtem_path/xtem_async $name &...", concrete e.g.:
# "... exec xterm       -e /usr/local/bin/wishx -f $xtem_path/xtem_async $name &..."
#
# Copyright (C) 1994  G. Lamprecht, W. Lotz, R. Weibezahn; LRW c/o Uni Bremen
# Copyright (C) 1996  G. Lamprecht, W. Lotz, R. Weibezahn; IWD, Bremen University

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; TestPut 4 PID=$pid"
  flush stdout
}

signal trap SIGHUP  {destroy .}
signal trap SIGTERM {destroy .}
signal trap SIGCHLD \
       {global pid;if ![catch "wait $pid"] {puts stdout "";flush stdout;send $xtem mkCmd_xit}}

signal ignore SIGINT
signal ignore SIGQUIT

set pid 0
wm withdraw .
set xtem [lindex $argv 0]
send $xtem  set n_mkCmd \"[winfo name .]\"
