I have a parent process and a forked child process, and they share the IPC Unix domain socket created with socketpair(AF_UNIX, SOCK_STREAM, 0, sockets). Both processes close one end of the socket socket and store the other end in a variable sock. After that they do this:
int sock;
void child_main()
{
printf("I am child\n");
sleep(1);
close(sock);
}
void parent_main()
{
printf("I am parent\n");
write(sock, "hello", 5);
char buf[100];
int ret = read(sock, buf, 100);
if (ret == -1) {
perror("read");
exit(-1);
}
}
The parent process writes some data to the socket, but the child does not read it. Instead, the child closes the socket. Now I am concerned that readthe parent process exited with ECONNRESET (Connection reset by peer), while I expect it to return "0" indicating the end of the stream. Because the other end of the socket was gracefully closed, calling close.
, ( ECONNRESET), ? man read ECONNRESET, :
, fd
unix :
ECONNRESET: .
Unix- IPC-, , , .
" " : , , close , , , ? ? , ?