merge SHUT_RD/EOF fix from a downstream source
fix GNUism