proc: avoid accidentally reading proc directory

as if it were a proc file.  There's no good that can come of that.
proc: handle empty/bogus proc files

without crashing in proc_foreach_helper().
proc: create & update proc files atomically

without leaving them in an empty or partially correct state on disk for
another process to attempt to read using proc_foreach().