qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] event: Add signal information to SHUTDOWN


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] event: Add signal information to SHUTDOWN
Date: Thu, 13 Apr 2017 14:11:32 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0


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

[Prev in Thread] Current Thread [Next in Thread]