A major limitation of iostream is that you can't have reads or writes with a safe interrupt. Instead rewrite the interface with Linux ppoll so that these can be safely interrupted with a signal and return early.