Add check-return routine trait

This allows us to easily check return values and throw an X::POSIX
exception if needed
Use check-return trait to get rid of redundant code