Permalink
Browse files

process, feat: process.exit support return 0;

  • Loading branch information...
xicilion committed Oct 29, 2017
1 parent 04f0b5d commit c4be76a4068c785281012d79076ef57d8d74fc41
@@ -43,6 +43,7 @@ class process_base : public EventEmitter_base {
static result_t umask(exlib::string mask, int32_t& retVal);
static result_t umask(int32_t& retVal);
static result_t hrtime(v8::Local<v8::Array> diff, v8::Local<v8::Array>& retVal);
static result_t exit();
static result_t exit(int32_t code);
static result_t cwd(exlib::string& retVal);
static result_t chdir(exlib::string directory);
@@ -342,9 +343,13 @@ inline void process_base::s_exit(const v8::FunctionCallbackInfo<v8::Value>& args
METHOD_NAME("process.exit");
METHOD_ENTER();
METHOD_OVER(1, 0);
METHOD_OVER(0, 0);
hr = exit();
OPT_ARG(int32_t, 0, 0);
METHOD_OVER(1, 1);
ARG(int32_t, 0);
hr = exit(v0);
@@ -84,8 +84,12 @@ void JSFiber::fiber_proc(void* p)
isolate->m_pendding.inc();
t._emit("beforeExit", &code, 1, r);
if (isolate->m_pendding.dec() == 0)
process_base::exit(hr);
if (isolate->m_pendding.dec() == 0) {
if (hr >= 0)
process_base::exit();
else
process_base::exit(hr);
}
}
}
@@ -251,14 +251,10 @@ result_t process_base::get_stderr(obj_ptr<File_base>& retVal)
return 0;
}
result_t process_base::exit(int32_t code)
result_t process_base::exit()
{
Isolate* isolate = Isolate::current();
if (code != 0)
isolate->m_exitCode = code;
else
code = isolate->m_exitCode;
int32_t code = isolate->m_exitCode;
JSTrigger t(isolate->m_isolate, class_info().getModule(isolate));
v8::Local<v8::Value> v = v8::Number::New(isolate->m_isolate, code);
@@ -278,6 +274,13 @@ result_t process_base::exit(int32_t code)
return 0;
}
result_t process_base::exit(int32_t code)
{
Isolate* isolate = Isolate::current();
isolate->m_exitCode = code;
return process_base::exit();
}
result_t process_base::memoryUsage(v8::Local<v8::Object>& retVal)
{
return os_base::memoryUsage(retVal);
@@ -32,7 +32,7 @@ static void _InterruptCallback(v8::Isolate* v8_isolate, void* data)
t._emit((const char*)data, NULL, 0, r);
if (!r)
_exit(1);
process_base::exit(1);
}
result_t async_signal(const char* name)
View
@@ -101,10 +101,13 @@ module process : EventEmitter
*/
static Array hrtime(Array diff = []);
/*! @brief 退出当前进程,并返回 exitCode 作为进程结果 */
static exit();
/*! @brief 退出当前进程,并返回结果
@param code 返回进程结果, 默认为 0,此时将使用 exitCode 作为进程结果
@param code 返回进程结果
*/
static exit(Integer code = 0);
static exit(Integer code);
/*! @brief 返回操作系统当前工作路径
@return 返回当前系统路径

0 comments on commit c4be76a

Please sign in to comment.