Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add process exit support #556

Merged
merged 2 commits into from Dec 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/modules/hooks.lua
Expand Up @@ -15,6 +15,9 @@ See the License for the specific language governing permissions and
limitations under the License.

--]]
local Manager = require('core').Emitter:extend()

return Manager:new()
-- Hooks are intended to be a global event emitter for internal
-- Luvit events. For example, process.exit and signals can feed
-- through this emitter.

return require('core').Emitter:new()
3 changes: 3 additions & 0 deletions app/modules/process.lua
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
--]]

local timer = require('timer')
local utils = require('utils')
local hooks = require('hooks')
local Emitter = require('core').Emitter

local function nextTick(...)
Expand All @@ -27,6 +29,7 @@ local function globalProcess()
local process = Emitter:new()
process.exitCode = 0
process.nextTick = nextTick
hooks:on('process.exit', utils.bind(process.emit, process, 'exit'))
return process
end
exports.globalProcess = globalProcess