fixed bugs regarding SIGPIPE