There is no reason to ever integrate any of these functions into a xxd-like program. Or almost any program.<p>Non-blocking I/O would ever only be used on pipe-like objects (sockets, serial ports, IPC pipes). There is no reason to use it if you are not multiplexing multiple I/O descriptors onto one thread. There is no point in making a single thread sit in a loop that calls read and write on a single non-blocking descriptor, and uses poll to block. You've just implemented a bunch of complexity in order to do blocking I/O, which you could get by not turning that descriptor non-blocking in the first place.<p>If you want to bring in POSIX-isms into an xxd-like program, consider mmaping the input (if it is a file) and then treating it as a big binary buffer to hexdump.<p>I see in your part 2/2 that you're not even calling readblock! The function is unused.<p>You are using writeall --- for flushing a "char buf [256]" static object when it fills up.<p>The fsync stuff is pointless; if someone cares, they can call the sync utility in a script after calling your program. Utilities like this should not be second-guessing the I/O subsystem. fsync is for database engines and whatnot. Actually it's pretty useless because it doesn't give hard guarantees. Just because something is flushed out of the operating system's buffers down to the hardware doesn't mean it's actually written into the storage device (disk surface or flash chips or whatever).<p>Calling fsync can only add a delay before your program terminates, making it look slower, so if you're after writing a fast xxd, why would you be calling it?