LIJI32 / SameBoy

Game Boy and Game Boy Color emulator written in C
https://sameboy.github.io/
Other
1.58k stars 205 forks source link

Add SIGUSR1 to reload to the SDL frontend #557

Closed arkie closed 11 months ago

arkie commented 11 months ago

Found this useful for quickly reloading after a change / compile - feel free to edit or close out if not wanted. Thanks!

LIJI32 commented 11 months ago

This looks good, but why SIGHUP rather than one of the USR signals? (I can see the signal being sent under some weird piping scenarios)

arkie commented 11 months ago

I used SIGHUP as it seems somewhat common for reload (e.g. I know kanshi uses it, and a quick search found similar usage for HashiCorp's Vault and haproxy's docker)

Using SIGUSR[12] would work as well, was mostly just following that convention (and haven't yet run into a non-manual SIGHUP trigger issue heh)

LIJI32 commented 11 months ago

I assumed that was the reason, since SIGHUP was reused for these things historically since USR1 and USR2 are a relatively recent addition. Opening SameBoy SDL from the terminal and closing the terminal window triggers a SIGHUP, so the current code will trigger a restart rather than a termination in that case (None of the options are ideal to be fair, since the latter will quit without saving while the former is quite unexpected). I'd use SIGUSR1 for this, if you can modify the PR I'll merge it.

arkie commented 11 months ago

Despite double-checking Wikipedia re: history before sending the PR, I was still thinking "ah, of course killing the terminal will kill the process since it owns the session, so the behavior should still be intact..."

Well, at least it was a good reminder on nohup vs setsid. Thanks for the review!