term: add term_shutdown()

This function unmaps the terminal window, removes itself from the
wayland list of terminals and then finally destroys itself.

We ensure we don't get any callbacks/events referring to a free:d
terminal struct, we close all terminal related FDs and unmap the
wayland window.

Then, to be really really sure there aren't any (by the FDM) queued up
events, we delay the self-destruction to the next FDM poll iteration,
by opening an event FD and adding it to the FDM.

The callback for the event FD removes the FD from the FDM again, and
closes it. And then proceeds to destroy the terminal.
This commit is contained in:
Daniel Eklöf 2019-10-30 20:03:11 +01:00
parent 445bbe3469
commit 9d5926ce12
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 103 additions and 32 deletions

View file

@ -293,6 +293,7 @@ struct config;
struct terminal *term_init(
const struct config *conf, struct fdm *fdm, struct wayland *wayl,
int argc, char *const *argv);
bool term_shutdown(struct terminal *term);
int term_destroy(struct terminal *term);
void term_reset(struct terminal *term, bool hard);