I've got some code that is basically Expect
<https://sourceforge.net/projects/expect/>-lite written in Go. I've got a
deadlock and I'm hoping someone here can help me untangle it. I posted this
yesterday but at the time I thought the Expect part of the code wasn't
relevant and I left it out. I now believe that part of the code *is* the
problem.

I have:

   1. exec.Command() with stdin and stdout replaced with io.Pipe()
   2. a Go routine listening to stdout, watching for strings, and writing
   to stdin

I know that Wait() won't return until stdin is closed. The problem is that
I can't tell when I need to close stdin. Since Wait() doesn't return, the
main thread can't do it. For some reason stdout doesn't get closed even
with the program exits (stdout.Read() is part of the deadlock) so the
Expect Go routine can't do it.

The only thing I can think of is *another* Go routine monitoring
cmd.ProcessState but that doesn't feel right.

What am I missing?

Thank you!

-- Salvatore
smile.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEQs7S8M_KTESzGPfaQsEHi9gVc1O_M5DAS4nKJ0SDn_Mqm3Tg%40mail.gmail.com.

Reply via email to