From 50eb6f4cf78a1fa04b9032e899410d24cc7d3fcb Mon Sep 17 00:00:00 2001 From: ubuntu201711081 <201711081@jbnu.ac.kr> Date: Fri, 4 Dec 2020 10:13:56 +0000 Subject: [PATCH] modify p-client child return value --- p-server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/p-server.c b/p-server.c index bb67be1..3783414 100644 --- a/p-server.c +++ b/p-server.c @@ -266,6 +266,7 @@ int main(int argc, const char *argv[]){ int fd, pid; char ip_buf[INET_ADDRSTRLEN]; const char * msg; + int retval = 0; if((csock = accept(sock, (struct sockaddr *)&client_addr,&client_addr_len)) < 0){ free(buf); perror("accept error"); @@ -276,13 +277,14 @@ int main(int argc, const char *argv[]){ pid = fork(); if(pid == 0){ if((fd = read_request(csock,buf,bufsize)) > 0){ - send_response(csock,fd,buf,bufsize); + retval = send_response(csock,fd,buf,bufsize); close(fd); } + else retval = fd; if(close(csock) < 0) perror("csock close error"); free(buf); - return 0; + return retval; } } for (i = 0; i < 3; i++)