summaryrefslogtreecommitdiff
path: root/procps/fuser.c
diff options
context:
space:
mode:
Diffstat (limited to 'procps/fuser.c')
-rw-r--r--procps/fuser.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/procps/fuser.c b/procps/fuser.c
index fd876d559..55f7917a0 100644
--- a/procps/fuser.c
+++ b/procps/fuser.c
@@ -208,6 +208,7 @@ static pid_list *scan_dir_links(const char *dname, pid_t pid,
208 return plist; 208 return plist;
209} 209}
210 210
211/* NB: does chdir internally */
211static pid_list *scan_proc_pids(inode_list *ilist) 212static pid_list *scan_proc_pids(inode_list *ilist)
212{ 213{
213 DIR *d; 214 DIR *d;
@@ -215,7 +216,8 @@ static pid_list *scan_proc_pids(inode_list *ilist)
215 pid_t pid; 216 pid_t pid;
216 pid_list *plist; 217 pid_list *plist;
217 218
218 d = opendir("."); 219 xchdir("/proc");
220 d = opendir("/proc");
219 if (!d) 221 if (!d)
220 return NULL; 222 return NULL;
221 223
@@ -329,7 +331,7 @@ Find processes which use FILEs or PORTs
329 pp++; 331 pp++;
330 } 332 }
331 333
332 plist = scan_proc_pids(ilist); 334 plist = scan_proc_pids(ilist); /* changes dir to "/proc" */
333 335
334 if (!plist) 336 if (!plist)
335 return EXIT_FAILURE; 337 return EXIT_FAILURE;