From e18ad0db1135a872305bcdcc660035925036f809 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 4 Aug 2018 01:25:35 +0100 Subject: [PATCH] WIP: Avoid Expect clobbering stdout when stdin isn't a tty. Doing expect_after before a child process has been spawned causes Expect to try reading from stdin. If stdin is /dev/null, it gets an EOF from the read, assumes it's been closed... and closes stdout too, so we don't see any more of the child process interaction. WIP because I've only done this for simh. --- build/build.tcl | 6 +++++- build/simh/build.tcl | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/build/build.tcl b/build/build.tcl index f4433f40..ba0a640e 100644 --- a/build/build.tcl +++ b/build/build.tcl @@ -106,7 +106,11 @@ proc build_macsyma_portion {} { } set timeout 100 -expect_after timeout abort +proc setup_timeout {} { + # Don't do this until after you've called "spawn", otherwise it'll cause a + # read from stdin which will return EOF if stdin isn't a tty. + expect_after timeout abort +} set ip [ip_address [lindex $argv 0]] set gw [ip_address [lindex $argv 1]] diff --git a/build/simh/build.tcl b/build/simh/build.tcl index 43df068e..35119f7d 100644 --- a/build/simh/build.tcl +++ b/build/simh/build.tcl @@ -4,6 +4,8 @@ set emulator_escape "\034" proc start_salv {} { uplevel #0 {spawn pdp10 build/simh/init} + setup_timeout + respond "sim>" "show ver\r" respond "sim>" "b tu1\r" expect "MTBOOT" @@ -23,6 +25,7 @@ proc start_dskdmp {} { proc start_its {} { uplevel #0 {spawn pdp10 build/simh/boot} + setup_timeout } proc mount_tape {file} {