Closed juliancnn closed 1 year ago
Well, first of all, is it possible in libuv
? If yes, how does it work?
uvw
adds nothing on top of libuv
, it only wraps the underlying library.
Therefore, the first thing to understand is if it works and how it works with libuv
.
Then we can map your findings to uvw
. 🙂
Thank you for your response and guidance. Following your suggestion, I've investigated this further and I believe I've identified the solution based on the capabilities of libuv.
The issue seems to stem from a signal known as SIGPIPE
, which is sent to a process when it attempts to write to a pipe without a reader. When this signal is not handled, the process gets terminated with a status code 141 indicating a broken pipe. This is exactly the situation I am experiencing when the client abruptly disconnects.
After doing some research, I came across these relevant resources:
SIGPIPE
and how it can be addressed.Based on these sources, the solution is to ignore the SIGPIPE
signal, allowing libuv to handle the situation and prevent the application from terminating unexpectedly. This can be done using the signal()
function like so:
signal(SIGPIPE, SIG_IGN);
By adding this line of code, any SIGPIPE
signals that occur are simply ignored, and libuv is allowed to manage the situation as it was designed to. This appears to have resolved the issue on my end.
I hope this solution can be of help to other developers who might encounter a similar issue. Let me know if there's anything else that should be addressed or explained further.
Hello,
I'm currently working on an application using UVW's PipeHandle to communicate via UNIX sockets. I've encountered a situation where the application unexpectedly exits with a status code 141 (which corresponds to a broken pipe) when a client abruptly closes the connection.
Here's the scenario: the server is processing a long task (like sleeping for several seconds :laughing: ), and during this time, the client (using netcat) forcefully closes the connection. In this situation, my application does not seem to catch this event with an
ErrorEvent
but rather exits with code 141.Could you please provide some guidance on how to handle this scenario? Should UVW's
ErrorEvent
be able to capture such a situation, or is there another event or method I should be using to prevent the application from terminating in this way?Steps to reproduce:
nc -U /tmp/zz_onlyCPP.sock
.wait 10
from netcat to make the server sleep for 10 seconds.ctrl+c
.Code to reproduce:
Toggle me!
```cpp #includeEnvironment: