kripken/emscripten — pull request #1449 by inolen (2013-07-30 18:12:21+00:00)
Title: update test_ccall to not use a postrun hook

This resolves https://github.com/kripken/emscripten/issues/1378

test_ccall was relying on the runtime being initialized during a postrun hook, which it isn't. However, since the current FS system wasn't destroying the streams during its teardown operation it was still working.

I've added JS interfaces for adding oninit, onpremain and onexit events, and updated test_ccall to using an onexit hook instead of a postrun hook.

I've also updated FS::quit to null out each stream entry.

Also to note, `return 0;` had to be replaced by a call to `exit(0);` to make the runtime actually exit when using callMain (as discussed https://github.com/kripken/emscripten/pull/1444).