proc bghandler {interp error opt} {
	puts stderr "BGError in $interp: {$error} $opt"
}

proc newSecondsLimit {iName} {
    set elapsed [expr {([clock milliseconds] - $::t0)/1000.0}]
    puts "NewSecondsLimit $iName $elapsed"
    after 200 set ::ok 1
    vwait ::ok
    puts "waited for $iName"
    
    set newLimit [expr {[clock seconds] + $::secsMore}]
    interp limit $iName time -seconds $newLimit -command [list newSecondsLimit $iName]
    return
}

set ::t0 [clock milliseconds]
set ::secsMore 2

set int1 [interp create]
interp alias $int1 bghandler {} bghandler
interp bgerror {} {bghandler {}}
interp bgerror $int1 [list bghandler $int1]

newSecondsLimit $int1

interp eval $int1 {
    for {set nloop 0} {$nloop < 10000000} {incr nloop} {
        if {sin($nloop) eq {}} {
		# We should never reach this... But we do
		puts "Break now, errorInfo: $::errorInfo"
		break
	}
    }
}

 	  	 
