vznnc: add poll() to check if stdin is alive

This is an attempt to solve a problem of stale vznnc.

vzmigrate runs vznnc -l via ssh in background, like this:

	ssh -L localhost:$port:localhost:$port $DEST vznnc -l $port $CMD &
	ssh_pid=$!

and then proceeds to other stuff. If that other stuff fails,
vzmigrate needs to do a rollback, so it kill ssh:

	kill -TERM $ssh_pid

The problem is while ssh itself is killed, vznnc on the $DEST is still
there sitting on accept(), not knowing that it's all gone.

The way this patch solves this is doing poll() on listening fd as well
as stdin and stdout. If there is data on listening fd it means we can
proceed as usual, calling connect(). If there's an error on stdin or
stdout it means we need to exit.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
2 files changed