From d55927571149cc1cc9b43ea6caf1e1cf3bcb00b8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 25 Sep 2014 21:48:30 +0800 Subject: [PATCH] Emit "exit" event for "process" when quitting. --- atom/browser/lib/init.coffee | 4 ++++ atom/renderer/lib/init.coffee | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 1802f4649d1e..ddfa56169611 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -52,6 +52,10 @@ setImmediate -> detail: message buttons: ['OK'] + # Emit 'exit' event on quit. + require('app').on 'quit', -> + process.emit 'exit' + # Load the RPC server. require './rpc-server.js' diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index 5ae2e11a644c..3fb4ceaabf42 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -24,6 +24,10 @@ require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init.js') global.require = require global.module = module +# Emit the 'exit' event when page is unloading. +window.addEventListener 'unload', -> + process.emit 'exit' + # Set the __filename to the path of html file if it's file: or asar: protocol. if window.location.protocol in ['file:', 'asar:'] pathname =