/*
- * 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,
* limitations under the License.
*/
-
-
-
#include <unistd.h>
#include <stdio.h>
#include <sys/time.h>
char buf[128] = {0, };
unsigned long cutime, cstime;
int i;
+ int ret = -1;
snprintf(buf, sizeof(buf), "/proc/%d/stat", (int)pid);
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);