deal with broken procfs

On several embedded platforms the procfs implementation might differ.
Deal with that correctly (fix fd resource leak).