[cgi] switch from pipe(2) to socketpair(2)

We can't use normal pipe(2)s with libevent in some cases.  Switch to
socketpair(2), which doesn't have the same problem.

This has the drawback that it doesn't prevent the CGI script from
reading stdout, for instance.  (sockets are two-way, pipes only one-way)
This commit is contained in:
Omar Polo 2021-10-02 17:20:56 +00:00
parent b618111a68
commit 403c422041
1 changed files with 2 additions and 2 deletions

4
ex.c
View File

@ -130,9 +130,9 @@ launch_cgi(struct iri *iri, struct cgireq *req, struct vhost *vhost,
{
int p[2], errp[2]; /* read end, write end */
if (pipe(p) == -1)
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, p) == -1)
return -1;
if (pipe(errp) == -1)
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, errp) == -1)
return -1;
switch (fork()) {