summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheron Spiegl <tspiegl@gmail.com>2020-06-10 18:49:28 -0500
committerTheron Spiegl <tspiegl@gmail.com>2020-06-10 18:49:28 -0500
commit931b513047e69ffc052f53540c2184e7ad8acfe4 (patch)
tree2db3cdf347c873773d25657217750d5d1bb273ae
parentbb02dbc75cde5623f742878e0d055acb98ccd8da (diff)
detach from processes that don't let us inspect registers, adjust debug output. firefox tabs crashing but trying to load only when launching first window with whatfiles, fine when attaching or opening second window.
-rw-r--r--README.md2
-rw-r--r--src/whatfiles.c16
2 files changed, 11 insertions, 7 deletions
diff --git a/README.md b/README.md
index 6430d42..9cce5e0 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ $ sudo make install
## Known issues:
-- Seems to run slowly and occasionally freeze when used to launch Firefox and Chromium. (Attaching to both with `-p [PID]` once they're running works fine.)
+- Tabs crash when `whatfiles` is used to launch Firefox. (Attaching with `-p [PID]` once it's running works fine, as does using `whatfiles` to launch a second Firefox window if one's already open.)
Thank you for your interest, and please also check out [Cloaker](https://github.com/spieglt/cloaker), [Nestur](https://github.com/spieglt/nestur), and [Flying Carpet](https://github.com/spieglt/flyingcarpet)!
diff --git a/src/whatfiles.c b/src/whatfiles.c
index 9681820..5294f88 100644
--- a/src/whatfiles.c
+++ b/src/whatfiles.c
@@ -187,7 +187,9 @@ bool step_syscall(pid_t current_pid, int proc_status, HashMap map)
res = ptrace(PTRACE_SYSCALL, current_pid, 0, 0);
if (res == -1L) DEBUG("ptrace() failed to resume");
} else {
- DEBUG("can't get registers\n");
+ DEBUG("can't get registers, detaching from %d\n", current_pid);
+ res = ptrace(PTRACE_DETACH, current_pid, 0, 0); // "Under Linux, a tracee can be detached in this way regardless of which method was used to initiate tracing."
+ if (res == -1L) DEBUG("ptrace() failed to detach from %d\n", current_pid);
}
return could_read;
}
@@ -305,15 +307,17 @@ int main(int argc, char* argv[])
}
// catch any traced process' or thread's next state change
pid = wait(&status);
- if (pid == -1) SYS_ERR("waiting for any child process failed");
+ if (pid == -1) SYS_ERR("whatfiles exiting");
if (WIFEXITED(status) || WIFSIGNALED(status)) {
- DEBUG("exited %d at entry to syscall\n", pid);
+ DEBUG("PID %d exited", pid);
+ // ok if this fails in case of process not in hashmap
err = remove_pid(pid, hashmap);
- DEBUG("deletion of %d from hashmap failed\n", pid);
- }
- if (WIFSTOPPED(status)) {
+ if (err) DEBUG(", was not in map", pid);
+ DEBUG("\n");
+ } else if (WIFSTOPPED(status)) {
/*bool could_read = */ step_syscall(pid, status, hashmap);
}
+
if (hashmap->used == 0) {
DEBUG("all children exited\n");
break;