diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-11-25 14:55:50 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-11-25 15:01:53 +0100 |
commit | aad3a64d63db22db3e506de973f9577d8205554d (patch) | |
tree | 28ce1bc67cc5d982f5723a4e1f48e0323d24e802 | |
parent | Merge pull request #14129 from jlxawk/hwdb-sensor-jumper-ezpad-go (diff) | |
download | systemd-aad3a64d63db22db3e506de973f9577d8205554d.tar.xz systemd-aad3a64d63db22db3e506de973f9577d8205554d.zip |
process-util: tweak get_process_cwd() when calling for own process
Let's bypass /proc if we can.
-rw-r--r-- | src/basic/process-util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index aaec6a6a99..842c879c4e 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -21,8 +21,8 @@ #include "alloc-util.h" #include "architecture.h" -#include "escape.h" #include "env-util.h" +#include "escape.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" @@ -34,6 +34,7 @@ #include "missing_sched.h" #include "missing_syscall.h" #include "namespace-util.h" +#include "path-util.h" #include "process-util.h" #include "raw-clone.h" #include "rlimit-util.h" @@ -500,6 +501,9 @@ int get_process_cwd(pid_t pid, char **cwd) { assert(pid >= 0); + if (pid == 0 || pid == getpid_cached()) + return safe_getcwd(cwd); + p = procfs_file_alloca(pid, "cwd"); return get_process_link_contents(p, cwd); |