Revision f64622c4

b/os-posix.c
62 62
    sigaction(SIGPIPE, &act, NULL);
63 63
}
64 64

  
65
static void termsig_handler(int signal)
65
static void termsig_handler(int signal, siginfo_t *info, void *c)
66 66
{
67
    qemu_system_shutdown_request();
67
    qemu_system_killed(info->si_signo, info->si_pid);
68 68
}
69 69

  
70 70
static void sigchld_handler(int signal)
......
77 77
    struct sigaction act;
78 78

  
79 79
    memset(&act, 0, sizeof(act));
80
    act.sa_handler = termsig_handler;
80
    act.sa_sigaction = termsig_handler;
81
    act.sa_flags = SA_SIGINFO;
81 82
    sigaction(SIGINT,  &act, NULL);
82 83
    sigaction(SIGHUP,  &act, NULL);
83 84
    sigaction(SIGTERM, &act, NULL);
b/sysemu.h
66 66
int qemu_shutdown_requested(void);
67 67
int qemu_reset_requested(void);
68 68
int qemu_powerdown_requested(void);
69
void qemu_system_killed(int signal, pid_t pid);
70
void qemu_kill_report(void);
69 71
extern qemu_irq qemu_system_powerdown;
70 72
void qemu_system_reset(void);
71 73

  
b/vl.c
1215 1215
static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
1216 1216
    QTAILQ_HEAD_INITIALIZER(reset_handlers);
1217 1217
static int reset_requested;
1218
static int shutdown_requested;
1218
static int shutdown_requested, shutdown_signal = -1;
1219
static pid_t shutdown_pid;
1219 1220
static int powerdown_requested;
1220 1221
static int debug_requested;
1221 1222
static int vmstop_requested;
......
1227 1228
    return r;
1228 1229
}
1229 1230

  
1231
void qemu_kill_report(void)
1232
{
1233
    if (shutdown_signal != -1) {
1234
        fprintf(stderr, "Got signal %d from pid %d\n",
1235
                         shutdown_signal, shutdown_pid);
1236
        shutdown_signal = -1;
1237
    }
1238
}
1239

  
1230 1240
int qemu_reset_requested(void)
1231 1241
{
1232 1242
    int r = reset_requested;
......
1300 1310
    qemu_notify_event();
1301 1311
}
1302 1312

  
1313
void qemu_system_killed(int signal, pid_t pid)
1314
{
1315
    shutdown_signal = signal;
1316
    shutdown_pid = pid;
1317
    qemu_system_shutdown_request();
1318
}
1319

  
1303 1320
void qemu_system_shutdown_request(void)
1304 1321
{
1305 1322
    shutdown_requested = 1;
......
1443 1460
            vm_stop(VMSTOP_DEBUG);
1444 1461
        }
1445 1462
        if (qemu_shutdown_requested()) {
1463
            qemu_kill_report();
1446 1464
            monitor_protocol_event(QEVENT_SHUTDOWN, NULL);
1447 1465
            if (no_shutdown) {
1448 1466
                vm_stop(VMSTOP_SHUTDOWN);

Also available in: Unified diff