common: improve G_IO_ERR | G_IO_HUP handling