Fix VTE on FreeBSD
Currently the master branch of VTE is completely unusable on FreeBSD because of issues introduced in recent commits. It fails with 'systemd not available', fdwalk error, and the terminal is blocked on reading from the pty. Here is the patch. It includes 3 commits:
spawn: Don't require systemd when systemd is disabled
VTE should not fail with 'systemd not available' when systemd is
disabled during the build.
spawn: Ignore EBADF in the fdwalk callback
The fallback implementation of fdwalk can call the callback with invalid
file descriptors on non-Linux systems because it doesn't know how to get
a list of valid file descriptors. Therefore, we have to ignore bad file
descriptor errors, otherwise the fdwalk call always fail.
pty: Fix _vte_pty_open_posix for non-Linux systems
Commit 387b0a4924c895d14c5776093274fecd13c23138 removes the function
fd_set_nonblocking and ports _vte_pty_open_posix to use
vte::libc::fd_set_nonblock. However, there is a mistake during the port.
fd_set_nonblocking uses vte::libc::FD& to specify the file descriptor,
but vte::libc::fd_set_nonblock uses int. The commit correctly converts
one of its callers, fd_setup, to call the new function with fd.get()
instead of fd, but it forgets to do so for _vte_pty_open_posix.
Therefore, operator bool is called on fd to convert it to a bool with
value 'true'. It gets converted again to int with value 1 for passing to
vte::libc::fd_set_nonblock. This causes the terminal to display a blank
window and hang forever because the vte::libc::fd_set_nonblock calls
operates on stdout instead of the pty.
To prevent this kind of mistake from being made again, this commit also
marks operator bool function as explicit.