자식 프로세스가 죽지 않습니다.
소스는 인터넷에서 가져온건데요. 테스트중 자식 프로세스가 죽지 않고 계속 만들어지고 없어지지가 않습니다. 어떤 문법이 문제인지좀 알려주세요.
while(1) {  /* main accept() loop */
            sin_size = sizeof(struct sockaddr_in);
            if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, \
                                                          &sin_size)) == -1) {
                perror("accept");
                continue;
            }
            printf("server: got connection from %s\n", \
                                               inet_ntoa(their_addr.sin_addr));
            if (!fork()) { /* this is the child process */
                 if (send(new_fd, "hello world!\n", 14, 0) == -1)
                  perror("send");
                 close(new_fd);
                 exit(0);
            }
             close(new_fd);  /* parent doesn't need this */
            while(waitpid(-1,NULL,WNOHANG) > 0); /* clean up child processes */
        }


이것 저것 테스트 하다 무한 루프 걸려 서버 리붓했습니다.
이것 저것 테스트 하다 무한 루프 걸려 서버 리붓했습니다.
댓글 달기