gui: Move external command handling out of do_select().
This commit moves the part of do_select() that deals with
external commands to separate functions, command_pre_select() and
command_post_select().
This change shortens do_select() considerably and is another step
towards the goal of using the paraslash scheduling system also for
para_gui.
One thing to note is that the new command_post_select() returns -1 if
both both fds are closed, i.e. when the currently running command has
terminated. This value gets translated back to zero in do_select(),
preserving the current semantics.