c - Can socket send fail cause a daemon program crash? -
i have 2 applications running on embedded linux board. 1 runs daemon , other acts interface it. communicate each other using unix sockets. handle abnormal termination of socket, tried terminating interface application [ctr+c]. result, daemon application crashes. since socket terminated, socket send failed error on daemon side, expected after daemon crashes. @ loss should debugging problem.
have set socket in daemon non-blocking mode ?
suppose code looks following:
while(1) { connfd = accept(listenfd, (struct sockaddr*)null, null);
/* use fd */ func(connfd);
}
based on man page:
" on success, accept() return nonnegative integer descriptor accepted socket. on error, -1 returned, , errno set appropriately.
and
if no pending connections present on queue, , socket not marked nonblocking, accept() blocks caller until connection present. if socket marked nonblocking , no pending connections present on queue, accept() fails error eagain or ewouldblock. "
therefore, means if in non-blocking mode, should check return value of accept() instead of using directly because fd value -1.
the above 1 common possibility. if not case, can try use "sudo strace -p process_id" or carry out core file analysis understand why crashed.