newmangj's is a good way, not very easy to do.
i propose the old way; scann the output of ps.
#define MYPS "/bin/ps -efopid,comm" /* on a solaris-os */
FILE *ps = popen(MYPS,"r"

;
while(fgets(buff,MAXBUFF,ps)){
if 'name' not in 'buff' continue;
pid = atoi(buff);
...
...
}
pclose(ps);
it my be old-fashioned, but it works ans is portable.
you only have to change the ps statement.
for the if use a string function. ------------ jamisar
Einfachheit ist das Resultat der Reife. (Friedrich Schiller)
Simplicity is the fruit of maturity.