in my c++ application in linux how can I get a service status (like service abc status in terminal when the abc is the service)
thanks
FILE * f = popen("service abc status", "r");
Then read from f with eg fgets
char Line[100];
while (fgets(Line, 100, f) != NULL)
cout << Line;
Remember to close the file:
int st = pclose(f);
Then you can check the exit code and such using the macros described in "man 2 wait" on st
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.