Second attempt in !10419. That one defers SIGUSR1 during the syscall entry path to after the context is saved. After that point SIGUSR1 is processed immediately, but also, if the interruption happened during the syscall exit path, the context restore is restarted (which allows any changes to the context to happen correctly). This does not fix the broader issue of other signals during kernel-mode code though. The reason why I'm processing the SIGUSR1 immediately is that I assume syscalls can block, and blocking SIGUSR1 possibly indefinitely is presumably a bad idea. So this MR strictly attempts to fix the "broken contexts" issue, not other bugs. But as far as I can tell, it should be a comprehensive fix for this. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10232#note_133212