简体   繁体   中英

In C++, how to get the path to a service in Linux?

Given the name of a service or daemon , is there some way by which I can get the location of that service from a C++ program in Linux ? I hope, one way is to search the proc filesystem using it pid . Does there exist some Linux functions for this?

Thank You

edit: To be more specific I am working on Linux equivalent code for this program in Windows.

You can execute the system function and redirect its output to a file. Later on read that file. For example,

system ("which rsyslogd >service.out");

Then in the program, you can read service.out.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM