Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 May 2014 23:35:51 +0200
From:      Thierry Thomas <thierry@FreeBSD.org>
To:        freebsd-ports@freebsd.org
Subject:   Patch wanted: VmRSS, VmSize and VmStk in /proc/pid/status
Message-ID:  <20140512213551.GE60374@graf.pompo.net>

next in thread | raw e-mail | index | archive | help
Hello,

In the new versions of french/aster, there is this piece of Linux code:

-----------------------------------------------------------
    static char filename[80];
    static char sbuf[1024];
    char* S;
    int fd, num_read;
    long lmem;
    pid_t numpro;

    pid_t getpid(void);

    numpro = getpid();

    sprintf(filename, "/proc/%ld/status", (long)numpro);
    fd = open(filename, O_RDONLY, 0);
    if (fd==-1) return -1;
    num_read=read(fd,sbuf,(sizeof sbuf)-1);
    close(fd);

    S=strstr(sbuf,"VmData:")+8;
    val[0] = (INTEGER)atoi(S);

    S=strstr(sbuf,"VmSize:")+8;
    val[1] = (INTEGER)atoi(S);

    if ( strstr(sbuf,"VmPeak:") != NULL ) {
        S=strstr(sbuf,"VmPeak:")+8;
        val[2] = atoi(S);
    } else {
        val[2] = -1 ;
    }

    S=strstr(sbuf,"VmRSS:")+7;
    val[3] = (INTEGER)atoi(S);

    S=strstr(sbuf,"VmStk:")+7;
    lmem = atoi(S);
    return lmem ;
-----------------------------------------------------------

Of course, it does'nt work on FreeBSD, because our status has a
different structure.

As a quick & dirty work-around, I patched it to replace /proc by
/compat/linux/proc and it works. Unfortunately, this is not a good
solution, because this port is no more packageable (this piece of code
is run at the end of the build).

It's why I'm looking for help here: does somebody knows how the
corresponding values of these Vm... can be found in FreeBSD?

Thanks,
-- 
Th. Thomas.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140512213551.GE60374>