Since using sysctl not been recommended for centuries, the recommended way to do this is to examine each of the process entries in /proc and read the comm file in each folder. If for your example the contents of this file are abc\n , then the process you are looking for.
I really don't speak C ++, but here is a possible solution in POSIX C89:
#include <glob.h>
Caution: if there are several running processes with the name you are looking for, this code will only return one. If you are going to change this, keep in mind that with a naive globe, you will also consider /proc/self/comm , which could potentially lead to duplicate entries.
If there are multiple processes with the same name, there really is no way to guarantee that you got the right one. For this reason, many daemons have the ability to save their files to a file; check your documentation.
source share