If fork fails, close the incoming socket

This commit is contained in:
Laslo Hunhold 2018-02-23 22:40:47 +01:00
parent 53c3963497
commit 72aa1646f6

6
main.c
View file

@ -237,13 +237,13 @@ main(int argc, char *argv[])
/* fork and handle */ /* fork and handle */
switch ((spid = fork())) { switch ((spid = fork())) {
case -1:
warn("fork:");
continue;
case 0: case 0:
serve(infd, &in_sa); serve(infd, &in_sa);
exit(0); exit(0);
break; break;
case -1:
warn("fork:");
/* fallthrough */
default: default:
/* close the connection in the parent */ /* close the connection in the parent */
close(infd); close(infd);