[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] MHD_create_response_from_fd using a pipe
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] MHD_create_response_from_fd using a pipe |
Date: |
Wed, 03 Jun 2015 07:57:45 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 |
On 06/03/2015 03:44 AM, Denis Dowling wrote:
> Then in my code when I want to return data from a process I do something like
>
> FILE *pf = popen(cmd, "r");
> int fd = fileno(pf);
>
> response = MHD_create_response_from_callback_fd(-1, 4096, &popen_reader,
> pf, &popen_free, fd);
Just do
int fd = dup (fileno (pf));
fclose (pf);
response = MHD_create_response_from_callback_fd(-1, 4096, &popen_reader,
pf, &popen_free, fd);
and you can avoid the awkward popen_free().
Happy hacking!
-Christian
signature.asc
Description: OpenPGP digital signature