sftp: Don't spin before the SSH process opens the slave pty

When OpenSSH starts, it closes all its open file descriptors, including
the slave pty which is used for handling the login.  This would cause
gvfsd-sftp to spin because the poll() call in handle_login would return
immediately with POLLHUP.  Open the slave pty in the parent process so
that poll() doesn't return POLLHUP and spin needlessly.

Once the login has been completed, the slave fd can be closed in the
parent process (this fixes an fd leak in the BSD openpty codepath).

This change is based on what sshfs does, and is also similar to how the
BSD openpty codepath behaves.

Although the problem occurs briefly for any login, it is most noticeable
when trying to connect to a server that drops SSH packets.
E.g. gvfs-mount sftp://8.8.8.8

https://bugzilla.gnome.org/show_bug.cgi?id=724780
pty_open: Fix warnings with BSD codepath

Fix warnings by conditionally compiling functions needed for the
UNIX98_PTY codepath.  Also, make a function static.

https://bugzilla.gnome.org/show_bug.cgi?id=724780
pty_open: Remove unused function prototype

https://bugzilla.gnome.org/show_bug.cgi?id=724780