mirror of
https://github.com/omar-polo/gmid.git
synced 2024-09-30 06:21:19 +02:00
don't leak a file descriptor
make sure we always close every fd in every possible code path; while there, also add a log_err if fork(2) failed.
This commit is contained in:
parent
a8a1f43921
commit
e7c6502bf3
6
ex.c
6
ex.c
@ -137,6 +137,11 @@ launch_cgi(struct iri *iri, struct cgireq *req, struct vhost *vhost,
|
||||
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
log_err(NULL, "fork failed: %s", strerror(errno));
|
||||
close(p[0]);
|
||||
close(p[1]);
|
||||
close(errp[0]);
|
||||
close(errp[1]);
|
||||
return -1;
|
||||
|
||||
case 0: { /* child */
|
||||
@ -230,6 +235,7 @@ launch_cgi(struct iri *iri, struct cgireq *req, struct vhost *vhost,
|
||||
|
||||
default:
|
||||
close(p[1]);
|
||||
close(errp[0]);
|
||||
close(errp[1]);
|
||||
mark_nonblock(p[0]);
|
||||
return p[0];
|
||||
|
Loading…
Reference in New Issue
Block a user