I have a simple program that connects a program's stdin, stdout and stderr to a socket, like this,
go func() {
defer conn.Close();
defer stdin.Close();
io.Copy(stdin, conn);
}();
go func() {
defer conn.Close();
defer stdout.Close();
defer stderr.Close();
io.Copy(conn, stdout);
io.Copy(conn, stderr);
}();
select{}
I have two problems,
- I have to keep these two goroutines running by doing a
select{}
- When the socket get disconnected, there's no way to tell it. I need to terminate the
select{}
loop if that happens.
Any ideas?