microcom
microcom copied to clipboard
Fix some UB in signal handling
While looking over #15, I noticed some issues with the way microcom handles signals. This fixes what was straight forward to fix. What remains is the access to ios, ios->exit and whatever is called there. With #15 merged, this could be fixed by peppering some volatile around, but it's very unlikely to happen so postponing this for now.
Sorry, github UI problems. I only intended to approve the first commit.
Hmm, I don't particularly like this. I'd like to allow backends calling async-unsafe functions.
We could longjmp back into main and exit regularly there. Thinking about it, I like this approach more as well. What do you think?
(EDIT: Thinking some more about this, this is non-nonsensical. If you call an async-signal-unsafe function after a longjmp, you run into UB as well.)
Freeing ios in global code seems to work, but is a layer violation because the structure was allocated in the backends.
Is it? malloc, calloc and strdup are all free'd by the same free. Same goes for open, socket and creat, which are all destructed by close.