diff options
-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); |