What\'s the rationale behind it? What would the bad consequences be if a process doing I/O is allowed to handle signal?
Now that I've read the book "The Design of the Unix Operating Systems" by Maurice Bach, let me answer this question by myself.
In short, making I/O uninterruptible is for the purpose of making the I/O task finish ASAP, without being interfered by signals.
Some related knowledge that I gained from the book:
According to the Linux Developers Documentation, it is to prevent data loss and avoid hardware getting into an inconsistent state.
Imagine what could occur if a read()
(such as from disk) were interruptible and the signal handler, among other duties, altered the read buffer. Since the signal is asynchronous, the read results would not be reproducible. Similar chaos would ensue if writing were interrupted.