Solved Server crash after client calls QtTcpSocket::disconnectFromHost();
-
Hi and welcome to devnet,
What are you using of the server ?
Please provide the stack trace of your crash.
-
I'm new to linux and I dont know how can I get the stack trace?
The server is running on a RaspberryPI.
The RaspberryPI is controlling my boiler and gathering some information like temperature, etc.
And the server is sending that information to the client so I can watch my boiler on my pc even when I'm not home. -
Use gdb to run your application.
-
This is the stack trace:
Thread 5 "test" received signal SIGPIPE, Broken pipe. [Switching to Thread 0xb4fff450 (LWP 7463)] __GI___libc_write (nbytes=52, buf=0xb50008a0, fd=5) at ../sysdeps/unix/sysv/linux/write.c:26 26 ../sysdeps/unix/sysv/linux/write.c: No such file or directory.
-
__libc_write (int fd, const void *buf, size_t nbytes) { return SYSCALL_CANCEL (write, fd, buf, nbytes); <- this is that line of code }
-
Are you using a QTcpServer ?
-
If not, are you handling that signal ? See here for some suggestions related to that.
-
Such a simple mistake I have not used TCP in such a long time that I forgot all about signals.
I was getting so frustrated trying to solve it for several hours.
Now it works, thank you so much! -
Just of curiosity, why does disconnectFromHost() sends a sigpipe but when I close application it does not send a sigpipe?
-
Sorry, I currently don't know although I am also intrigued.