The setup is below.
have a X11 connection file descriptor(`x11_fd`) set in non-blocking mode. have a signal file descriptor(`sig_fd`) set in non-blocking