Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/dinitctl.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cstdio>
#include <cstddef>
#include <cstring>
#include <optional>
#include <string>
#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down