If itโs easy to use,
char buf[512]; FILE *cmd_pipe = popen("pidof -s process_name", "r"); fgets(buf, 512, cmd_pipe); pid_t pid = strtoul(buf, NULL, 10); pclose( cmd_pipe );
- way.
Yes, this is ugly, I know. It is much better to go and read the pidof source code.
source share