On 12/04/2017 19:02, Markus Armbruster wrote:
>>                           Note that mingw lacks decent signal
>> support, and will never report a signal because it never calls
>> qemu_system_killed().
> 
> Awkward.

ISO C trivia of the day: "kill" is only a POSIX function.

> os-posix.c arranges for SIGINT, SIGHUP and SIGTERM to be caught.  Here's
> the handler:
> 
>     static void termsig_handler(int signal, siginfo_t *info, void *c)
>     {
>         qemu_system_killed(info->si_signo, info->si_pid);
>     }
> 
>     void qemu_system_killed(int signal, pid_t pid)
>     {
>         shutdown_signal = signal;
>         shutdown_pid = pid;
>         no_shutdown = 0;
> 
>         /* Cannot call qemu_system_shutdown_request directly because
>          * we are in a signal handler.
>          */
>         shutdown_requested = 1;
>         qemu_notify_event();
>     }
> 
> The variables are all int or pid_t.  Works in practice (pedants might
> ask for sig_atomic_t, but I won't).
> 
> In other words, these three signals are polite requests to terminate
> QEMU.
> 
> Stefan, are there equivalent requests under Windows?  I guess there
> might be one at least for SIGINT, namely whatever happens when you hit
> ^C on the console.

SIGINT and SIGBREAK exist, so you can just use a termsig_handler which
passes 0 for the pid.

Paolo

Reply via email to