# -*- tcl -*-
# Script to boot a child running an open comm server

set spawncode [asset slave.tcl]

proc slaveat {id} {
    #puts "Slave @ $id"
    proc slave {} [list return $id]
    set ::go .
}

#puts "self @ [::comm::comm self]"

exec \
    [info nameofexecutable] $spawncode \
    [tcllibPath snit/snit.tcl] \
    [localPath  .. comm.tcl] \
    [::comm::comm self] &

#puts "Waiting for spawned comm system to boot"
# Wait for the slave to initialize itself.
vwait ::go

#puts "Running tests"
#::comm::comm debug 1

proc slavestop {} {
    ::comm::comm send -async [slave] {{exit}}
    ::comm::comm abort
    removeFile spawn
    return
}
