Re: "broken pipe", but not when debugging...
Thank you for the opportunity to expound on this. See below…
A look at the discussion for NSFileHandle’s writeData: method provides the following:
"This method raises an exception if the file descriptor is closed or is not valid, if the receiver represents an unconnected pipe or socket endpoint, if no free space is left on the file system, or if any other writing error occurs.”
The exception is caused directly by the broken pipe. The exception handler is picking it up so that a try-catch block can directly handle and correct for it. The same text is in the availableData method. I tend to be very defensive in my code, especially in areas where
external forces can cause problems. This is one such area. After I started using try-catch blocks around these methods the crash issues disappeared.
I believe there are many other issues that the Cocoa frameworks handle with exceptions that we used to handle otherwise - that is with signal handling. I still have some signal handling code, but for the most part it has mostly gone away as we move more into the
try-catch exception handling world. Perhaps this is why it is more difficult to find docs for this things. Having said that, ioctl is so important that it must be available.
In any case, learning to use try-catch has been very beneficial!