Fix signal handler
The functions "ioctl" and "exit" do not belong to the list of async-signal-safe functions. I guess that a different program design will be needed for your functions "gpm_winch_hook" and "killed".
@elfring It is nice to point out - are you going to submit a PR later on?
Would you like to consider software design options like the following?
In theory yes, the question is more about who is going to implement them, I guess
Are you willing to dedicate another thread for receiving of notifications by the function "sigwaitinfo" or "select"?
that random link is broken now, so here's the official list of async-signal-safe functions.
wrt kill, none of those funcs are safe -- printf (via CLEAR), fprintf, or exit. I/O streams can be holding locks when the signal comes in, and exit can run atexit handlers which can do anything. so that func should be changed to use write;fsync;_exit and it should be fine.