Hi,

I have a program that needs to find another particular process if it
is running.  It used to do this by grovelling though /proc/pid/status,
looking for the particular program name.  Essentially, I would do the
following:

        stat ( "/proc", &sb );
        fd = open ( "/proc", O_RDONLY );
        while (!done) {
          n = getdirentries ( fd, buf, sb.st_blksize, &basep );
          /* check each /proc/pid/status file */
        }

It seems as though stat() used to return a non-zero value for
st_blksize for /proc, but these days it does not (it's hard for me to
tell exactly when this happened, perhaps somewhere around revision
1.73 of src/sys/kern/vfs_vnops.c, but I'm not positive).

The man page for getdirentries() says:

        int
        getdirentries(int fd, char *buf, int nbytes, long *basep)

        "The nbytes argument must be greater than or equal to the block
        size associated with the file, see stat(2).  Some filesys-
        tems may not support these functions with buffers smaller than
        this size."

So ... what are we supposed to use for this?  For special filesystems
like /proc, is any old value that is sufficiently large enough to hold
a few struct dirent's considered to be OK?  Should I not use
'getdirentries()', and opt instead for 'opendir()' and 'readdir()'?

Any advice is appreciated.

Thanks,
-Brian
-- 
Brian Dean
[EMAIL PROTECTED]



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to