Complete cleanup of pstat linux
This commit was SVN r24701.
Этот коммит содержится в:
родитель
08c3ecd608
Коммит
4083e23073
@ -280,43 +280,25 @@ static int query(pid_t pid,
|
|||||||
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
|
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 > (fd = open(data, O_RDONLY))) {
|
if (NULL == (fp = fopen(data, "r"))) {
|
||||||
/* can't access this file - most likely, this means we
|
/* ignore this */
|
||||||
* aren't really on a supported system, or the proc no
|
return OPAL_SUCCESS;
|
||||||
* longer exists. Just return an error
|
|
||||||
*/
|
|
||||||
return OPAL_ERR_FILE_OPEN_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* absorb all of the file's contents in one gulp - we'll process
|
|
||||||
* it once it is in memory for speed
|
|
||||||
*/
|
|
||||||
memset(data, 0, sizeof(data));
|
|
||||||
len = read(fd, data, sizeof(data)-1);
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
/* remove newline at end */
|
|
||||||
data[len] = '\0';
|
|
||||||
|
|
||||||
/* parse it according to proc(3) */
|
/* parse it according to proc(3) */
|
||||||
/* look for VmPeak */
|
while (NULL != (dptr = local_getline(fp))) {
|
||||||
if (NULL != (ptr = strstr(data, "VmPeak:"))) {
|
if (NULL == (value = local_stripper(dptr))) {
|
||||||
/* found it - step past colon */
|
/* cannot process */
|
||||||
ptr += 8;
|
continue;
|
||||||
stats->peak_vsize = convert_value(ptr);
|
}
|
||||||
}
|
/* look for VmPeak */
|
||||||
/* look for VmSize */
|
if (0 == strncmp(dptr, "VmPeak", strlen("VmPeak"))) {
|
||||||
if (NULL != (ptr = strstr(data, "VmSize:"))) {
|
stats->peak_vsize = convert_value(value);
|
||||||
/* found it - step past colon */
|
} else if (0 == strncmp(dptr, "VmSize", strlen("VmSize"))) {
|
||||||
ptr += 8;
|
stats->vsize = convert_value(value);
|
||||||
stats->vsize = convert_value(ptr); /* convert to MBytes*/
|
} else if (0 == strncmp(dptr, "VmRSS", strlen("VmRSS"))) {
|
||||||
}
|
stats->rss = convert_value(value);
|
||||||
|
}
|
||||||
/* look for RSS */
|
|
||||||
if (NULL != (ptr = strstr(data, "VmRSS:"))) {
|
|
||||||
/* found it - step past colon */
|
|
||||||
ptr += 8;
|
|
||||||
stats->rss = convert_value(ptr); /* convert to MBytes */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user