process-util: tweak get_process_cwd() when calling for own process

Let's bypass /proc if we can.
This commit is contained in:
Lennart Poettering 2019-11-25 14:55:50 +01:00
parent 1a92b3f2ec
commit aad3a64d63
1 changed files with 5 additions and 1 deletions

View File

@ -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);