properly check ios::bad since permission checks in /proc are broken