diff --git a/src/dinitctl.cc b/src/dinitctl.cc index 1945c52b..ba47b8d1 100644 --- a/src/dinitctl.cc +++ b/src/dinitctl.cc @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,7 @@ static int trigger_service(int socknum, cpbuffer_t &rbuffer, const char *service static int cat_service_log(int socknum, cpbuffer_t &rbuffer, const char *service_name, bool do_clear); static int signal_send(int socknum, cpbuffer_t &rbuffer, const char *service_name, sig_num_t sig_num); static int signal_list(); +static std::string get_service_description_dir(int socknum, cpbuffer_t &rbuffer, handle_t service_handle); enum class ctl_cmd { NONE, @@ -1735,6 +1737,20 @@ static int service_status(int socknum, cpbuffer_t &rbuffer, const char *service_ if (service_pid != -1) { cout << " Process ID: " << service_pid << "\n"; } + + + handle_t from_handle; + + if (!load_service(socknum, rbuffer, service_name, &from_handle, nullptr)) { + // TODO: handle error here? + } else { + std::string service_dir = get_service_description_dir(socknum, rbuffer, from_handle); + if (!service_dir.empty()) { + std::string path = service_dir + "/" + service_name; + cout << " Path: " << path << "\n"; + } + } + } return 0; @@ -1832,6 +1848,7 @@ static int shutdown_dinit(int socknum, cpbuffer_t &rbuffer, bool verbose) } // Get the service description directory for a loaded service +// Returns empty string when cannot find the directory static std::string get_service_description_dir(int socknum, cpbuffer_t &rbuffer, handle_t service_handle) { auto m = membuf()