You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run findex-daemon even though there are a few instances of findex running, I get the following error:
thread 'main' panicked at crates/findex-daemon/src/main.rs:32:28:
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
After digging in, I realised that the pidof command uses a space to separate multiple PIDs by default (see man), while getpid splits the output using newline bytes. A simple solution is to split using spaces:
However, this feels like a naive way as not all Linux systems have procps-ng out of the box. Instead, you could use the processes_by_name method of the sysinfo crate. Of course, that comes at the expense of the binary size. (But this is Rust after all, right?)
Of course, the simpler way would be to store the PIDs in the filesystem (like in /var/run). This way, we would not have to execute syscalls repeatedly. When the process exits, the PID can be removed from the store. (If that is too hard to implement, you could simple use kill(2) with a 0 signal to check if there a process with that PID is running.)
When I run
findex-daemon
even though there are a few instances offindex
running, I get the following error:After digging in, I realised that the
pidof
command uses a space to separate multiple PIDs by default (see man), whilegetpid
splits the output using newline bytes. A simple solution is to split using spaces:However, this feels like a naive way as not all Linux systems have
procps-ng
out of the box. Instead, you could use theprocesses_by_name
method of thesysinfo
crate. Of course, that comes at the expense of the binary size. (But this is Rust after all, right?)Of course, the simpler way would be to store the PIDs in the filesystem (like in
/var/run
). This way, we would not have to execute syscalls repeatedly. When the process exits, the PID can be removed from the store. (If that is too hard to implement, you could simple usekill(2)
with a 0 signal to check if there a process with that PID is running.)References
The text was updated successfully, but these errors were encountered: