Remove SMACK rule file(.rule) according three domain model
[apps/core/preloaded/taskmanager.git] / src / _cpu.c
index ee5cb18..0aaa89d 100755 (executable)
@@ -1,11 +1,12 @@
 /*
- * Copyright 2012  Samsung Electronics Co., Ltd
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  *
- * Licensed under the Flora License, Version 1.0 (the License);
+ * Licensed under the Flora License, Version 1.1 (the License);
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.tizenopensource.org/license
+ *     http://floralicense.org/license/
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an AS IS BASIS,
@@ -14,9 +15,6 @@
  * limitations under the License.
  */
 
-
-
-
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/time.h>
@@ -38,6 +36,7 @@ int _get_stat_info(pid_t pid, unsigned int *ut, unsigned int *st)
        char buf[128] = {0, };
        unsigned long cutime, cstime;
        int i;
+       int ret = -1;
 
        snprintf(buf, sizeof(buf), "/proc/%d/stat", (int)pid);
 
@@ -46,8 +45,14 @@ int _get_stat_info(pid_t pid, unsigned int *ut, unsigned int *st)
        fp = fopen(buf, "r");
        if (fp) {
                retvm_if(fp == NULL, -1, "Failed to open %s\n", buf);
-               fscanf(fp, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu %lu %ld %ld",
+               ret = fscanf(fp, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu %lu %ld %ld",
                                ut, st, &cutime, &cstime);
+               if(ret < 0)
+               {
+                       _E("Failed to fscanf() \n");
+                       fclose(fp);
+                       return -1;
+               }
                *ut += cutime;
                *st += cstime;
                fclose(fp);