From 4abfc2ced2cf77e0cc163b6d73510251321b98e1 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Tue, 22 Apr 2014 20:00:59 +0800 Subject: [PATCH] return 0 while task_info error --- lualib-src/lua-profile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lualib-src/lua-profile.c b/lualib-src/lua-profile.c index 2501600f..f0f11270 100644 --- a/lualib-src/lua-profile.c +++ b/lualib-src/lua-profile.c @@ -1,7 +1,6 @@ #include #include - #include #if defined(__APPLE__) @@ -25,7 +24,9 @@ get_time() { #else struct task_thread_times_info aTaskInfo; mach_msg_type_number_t aTaskInfoCount = TASK_THREAD_TIMES_INFO_COUNT; - assert(KERN_SUCCESS == task_info(mach_task_self(), TASK_THREAD_TIMES_INFO, (task_info_t )&aTaskInfo, &aTaskInfoCount)); + if (KERN_SUCCESS != task_info(mach_task_self(), TASK_THREAD_TIMES_INFO, (task_info_t )&aTaskInfo, &aTaskInfoCount)) { + return 0; + } int sec = aTaskInfo.user_time.seconds & 0xffff; int msec = aTaskInfo.user_time.microseconds;