karlseguin / http.zig

An HTTP/1.1 server for zig
MIT License
533 stars 41 forks source link

Add std.os.maybeIgnoreSigpipe to ignore SIGPIPE errors #8

Closed marijnfs closed 1 year ago

marijnfs commented 1 year ago

On linux by default the SIGPIPE signal kills your program. Zig actually by default registers a handler to avoid this, but this doesn't count for spawned threats.

So basically currently when I reload a page very quickly (hold down shift-r in firefox) I can crash the application because it either opens too many ports or reuses one, not sure. By calling maybeIgnoreSigpipe, an empty pipehandler is registered for the threads handling connections, avoiding the crash.