bug in libc with glob and /proc?

Ed Peschko horos22@gmail.com
Wed May 16 02:29:00 GMT 2018


all,

i'm getting something very odd with glob and /proc:

I am trying to write a quick process check module - one that I want to
be exceedingly small and therefore to have the fewest possible
dependencies (ie: no libproc)

So I was writing calls like this:

        proc_stat = glob("/proc/[0-9]*/cmdline", 0, NULL, &paths);
        ...
        globfree(&paths)


Oddly, this only returns results on the very first call - the second
returns that no results are to be found (GLOB_NOMATCH).

If however, I replace "/proc" with "/tmp" or any other value, it works
robustly - the only line of code changing being the call to glob.

Hence I really don't think it is a coding error on my part (i'll post
the full code if so desired).

Therefore, I'm leaning towards thinking it is a glibc bug and will
file it as so if necessary. This is on centos 7.5 btw for context.

so - what is going on here? weird things are also happing here when I
try to popen out and do the same logic against /proc.

 Is there something about /proc that is special here? Shouldn't glibc
be able to handle it transparently?

thanks much for any info/help..



More information about the Libc-help mailing list