As far as I know does ps on Linux internally loop over the directories (corresponding to process ids) found under /proc. So I think there is no single function doing that, you'd have to loop over the subdirectories of /proc yourself (using more generic POSIX functions such as readdir etc.).