Thanks for testing. I can't say I like my patch, however, as it's still error-prone and fragile. How about some new functions to the C API: rb_syserr_fail_str(VALUE mesg, int errnum); rb_syserr_fail(const char *mesg, int errnum); And deprecate rb_sys_fail and rb_sys_fail_str.