fix to flush a buffer by USR1 signal even on error happening