Added workaround to avoid SIGPIPE.

It should be fixed if there will be time for this.