Skip to content

Commit

Permalink
ui/cocoa: Do not exit immediately after shutdown
Browse files Browse the repository at this point in the history
ui/cocoa used to call exit immediately after calling
qemu_system_shutdown_request, which prevents QEMU from actually
perfoming system shutdown. Just sleep forever, and wait QEMU to call
exit and kill the Cocoa thread.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20210219111652.20623-1-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
akihikodaki authored and kraxel committed Mar 15, 2021
1 parent 14c235e commit 40c0193
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ui/cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,13 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification
COCOA_DEBUG("QemuCocoaAppController: applicationWillTerminate\n");

qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
exit(0);

/*
* Sleep here, because returning will cause OSX to kill us
* immediately; the QEMU main loop will handle the shutdown
* request and terminate the process.
*/
[NSThread sleepForTimeInterval:INFINITY];
}

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
Expand Down

0 comments on commit 40c0193

Please sign in to comment.