Repository navigation
Conversation
|
The pseudo-code looks strange to me. Setting a boolean to exit the loop without popping the listener socket is odd, as it means the loop won't exit until a new connection is attempted, at which point the connection will be accepted/handled but then the loop willl immediately exit right afterwards. I believe the convention here would be to call |
|
closing of the socked is handled by EINT is the code for Interrupted and already causes accept(2) to return |
Right, that's why you call |
|
doing so in the example I provided would require hosting the server instance out from main into global scope which I would rather try and avoid, but I'll give it a shot and see how it behaves and report back |
|
oh i missed that because I had to call |
|
yep that worked |
when a signal such as SIGINT or SIGTERM is received by a program under the default circumstances, it will cause the program to terminate immediately.
if however a listener for these is added using
signal(2)orsigaction(2)then it is possible to run a function as a result of the signal instead and syscalls currently blocking will exit with EINTR.however under status quo the logic used by
std.os.accept()and thusstd.http.Serverand any others, this error is undetectable and unable to be handled. now in any other case this errno result is perfectly resumable, but the consumer of std.os.accept() is likely already running a loop of their own that they can then continue through when getting this new error. most notably, is that it allows for a safe and proper exit. consider the following pseudo code