diff options
-rw-r--r-- | procps/lsof.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/procps/lsof.c b/procps/lsof.c index 7e0ffa4e5..b0156a538 100644 --- a/procps/lsof.c +++ b/procps/lsof.c @@ -61,9 +61,12 @@ int lsof_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) d_fd = opendir(name); if (d_fd) { while ((entry = readdir(d_fd)) != NULL) { - if (entry->d_type == DT_LNK) { - safe_strncpy(name + baseofs, entry->d_name, 10); - fdlink = xmalloc_readlink(name); + /* Skip entries '.' and '..' (and any hidden file) */ + if (entry->d_name[0] == '.') + continue; + + safe_strncpy(name + baseofs, entry->d_name, 10); + if ((fdlink = xmalloc_readlink(name)) != NULL) { printf("%d\t%s\t%s\n", proc->pid, proc->exe, fdlink); free(fdlink); } |