
proc readProgA {pid} {
  global readProgADone;

  # read outputs of schemdb
  set tmpbuf [gets $pid];
  puts "received $tmpbuf\n";

  set readProgADone [eof $pid];

  if {$readProgADone} {
    puts "closing...";
    catch [close $pid] aa;
    if {$aa != ""} {
      puts "HERE1: Error on closing";
      exit 1;
    }
  }
}

# set the "read" event
fileevent stdin readable {readProgA stdin};

