mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-30 14:53:11 +00:00
Add some FLOG logging around internal processes
This commit is contained in:
parent
61292b0c6c
commit
f3ee6a99c3
5 changed files with 27 additions and 3 deletions
|
@ -495,14 +495,16 @@ inline wcstring to_string(long x) {
|
||||||
return wcstring(buff);
|
return wcstring(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline wcstring to_string(int x) { return to_string(static_cast<long>(x)); }
|
inline wcstring to_string(unsigned long long x) {
|
||||||
|
|
||||||
inline wcstring to_string(size_t x) {
|
|
||||||
wchar_t buff[64];
|
wchar_t buff[64];
|
||||||
format_ullong_safe(buff, x);
|
format_ullong_safe(buff, x);
|
||||||
return wcstring(buff);
|
return wcstring(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline wcstring to_string(int x) { return to_string(static_cast<long>(x)); }
|
||||||
|
|
||||||
|
inline wcstring to_string(size_t x) { return to_string(static_cast<unsigned long long>(x)); }
|
||||||
|
|
||||||
inline bool bool_from_string(const std::string &x) {
|
inline bool bool_from_string(const std::string &x) {
|
||||||
if (x.empty()) return false;
|
if (x.empty()) return false;
|
||||||
switch (x.front()) {
|
switch (x.front()) {
|
||||||
|
|
|
@ -369,6 +369,9 @@ static bool run_internal_process(process_t *p, std::string outdata, std::string
|
||||||
p->internal_proc_ = std::make_shared<internal_proc_t>();
|
p->internal_proc_ = std::make_shared<internal_proc_t>();
|
||||||
f->internal_proc = p->internal_proc_;
|
f->internal_proc = p->internal_proc_;
|
||||||
|
|
||||||
|
FLOGF(proc_internal_proc, "Created internal proc %llu to write output for proc '%ls'",
|
||||||
|
p->internal_proc_->get_id(), p->argv0());
|
||||||
|
|
||||||
// Resolve the IO chain.
|
// Resolve the IO chain.
|
||||||
// Note it's important we do this even if we have no out or err data, because we may have been
|
// Note it's important we do this even if we have no out or err data, because we may have been
|
||||||
// asked to truncate a file (e.g. `echo -n '' > /tmp/truncateme.txt'). The open() in the dup2
|
// asked to truncate a file (e.g. `echo -n '' > /tmp/truncateme.txt'). The open() in the dup2
|
||||||
|
|
|
@ -59,6 +59,8 @@ class category_list_t {
|
||||||
|
|
||||||
category_t proc_termowner{L"proc-termowner", L"Terminal ownership events"};
|
category_t proc_termowner{L"proc-termowner", L"Terminal ownership events"};
|
||||||
|
|
||||||
|
category_t proc_internal_proc{L"proc-internal-proc", L"Internal (non-forked) process events"};
|
||||||
|
|
||||||
category_t env_locale{L"env-locale", L"Changes to locale variables"};
|
category_t env_locale{L"env-locale", L"Changes to locale variables"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -214,8 +214,17 @@ void internal_proc_t::mark_exited(proc_status_t status) {
|
||||||
status_.store(status, std::memory_order_relaxed);
|
status_.store(status, std::memory_order_relaxed);
|
||||||
exited_.store(true, std::memory_order_release);
|
exited_.store(true, std::memory_order_release);
|
||||||
topic_monitor_t::principal().post(topic_t::internal_exit);
|
topic_monitor_t::principal().post(topic_t::internal_exit);
|
||||||
|
FLOG(proc_internal_proc, "Internal proc", internal_proc_id_, "exited with status",
|
||||||
|
status.status_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int64_t next_proc_id() {
|
||||||
|
static std::atomic<uint64_t> s_next{};
|
||||||
|
return ++s_next;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal_proc_t::internal_proc_t() : internal_proc_id_(next_proc_id()) {}
|
||||||
|
|
||||||
static void mark_job_complete(const job_t *j) {
|
static void mark_job_complete(const job_t *j) {
|
||||||
for (auto &p : j->processes) {
|
for (auto &p : j->processes) {
|
||||||
p->completed = 1;
|
p->completed = 1;
|
||||||
|
|
|
@ -113,6 +113,10 @@ class proc_status_t {
|
||||||
/// A structure representing a "process" internal to fish. This is backed by a pthread instead of a
|
/// A structure representing a "process" internal to fish. This is backed by a pthread instead of a
|
||||||
/// separate process.
|
/// separate process.
|
||||||
class internal_proc_t {
|
class internal_proc_t {
|
||||||
|
/// An identifier for internal processes.
|
||||||
|
/// This is used for logging purposes only.
|
||||||
|
const uint64_t internal_proc_id_;
|
||||||
|
|
||||||
/// Whether the process has exited.
|
/// Whether the process has exited.
|
||||||
std::atomic<bool> exited_{};
|
std::atomic<bool> exited_{};
|
||||||
|
|
||||||
|
@ -130,6 +134,10 @@ class internal_proc_t {
|
||||||
assert(exited() && "Process is not exited");
|
assert(exited() && "Process is not exited");
|
||||||
return status_.load(std::memory_order_relaxed);
|
return status_.load(std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t get_id() const { return internal_proc_id_; }
|
||||||
|
|
||||||
|
internal_proc_t();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A structure representing a single fish process. Contains variables for tracking process state
|
/// A structure representing a single fish process. Contains variables for tracking process state
|
||||||
|
|
Loading…
Reference in a new issue