From: jzhang918 on
Hi,

I have a question about spawn an Expect script from another Expect
script.

$ cat foo
#!/usr/bin/expect -f

log_user 0
spawn "./bar"
expect {
eof {
set s [wait]
puts "[llength $s]"
puts "[lindex $s 0] [lindex $s 1] [lindex $s 2] [lindex $s 3]"
if { [llength $s] > 4 } {
puts " [lindex $s 4] [lindex $s 5] [lindex $s 6]"
exit 1
}
exit 0
}
}
$ cat bar
#!/usr/bin/expect -f

If I run ./foo, sometimes I got what I expect

$ ./foo
4
7868 exp6 0 0

sometimes I got what I don't expect

$ ./foo
7
7880 exp6 0 0
CHILDKILLED SIGHUP hangup

I don't know why this happens. How can I change the script to get the
result I expect?

The following line works:

spawn -ignore SIGHUP "./bar"

But I still don't know why bar will exit with signal SIGHUP sometimes.
If I compile an empty C program to replace Expect bar, it always
works:

$ cat bar.c
int main ()
{
return 0;
}

Thanks!

Jie