Replace readdir with readdir_r

Be safe in a multiple-thread environment.
Fix translating pid between namespaces
Fix readdir /proc file visibility check