Allow C-API IO system calls to be interrupted

This didn't setup the proper interrupt state so it would interrupt with
a signal.

Fixes #3042