libmicrohttpd
[Top][All Lists]
Advanced

[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: Thu, 04 Jun 2015 07:33:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0

Ah, right, sorry. I somehow read 'fclose' where it said 'pclose'. My
bad.  I believe Evgeny is preparing some new response callbacks for your
case already...

-Christian

On 06/04/2015 12:51 AM, Denis Dowling wrote:
> Hi Christian,
> 
> The manual page for popen is fairly explicit that pclose() must be used to 
> close the FILE returned from popen(). The pclose() call does some extra 
> process cleanup steps. I cannot see another way of doing this except using a 
> hybrid of MHD_create_response_from_callback and MHD_create_reponse_from_fd().
> 
> Regards,
> Denis
> 
> -----Original Message-----
> From: address@hidden [mailto:address@hidden On Behalf Of Christian Grothoff
> Sent: Wednesday, 3 June 2015 3:58 PM
> To: address@hidden
> Subject: Re: [libmicrohttpd] MHD_create_response_from_fd using a pipe
> 
> 
> 
> 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
> 
> 
> ________________________________
> 
> 
> The information contained in this message and any attachments is strictly 
> confidential and intended solely for the use of the intended recipient(s). 
> The copyright in this communication belongs to  (HSD). This message and any 
> attachments are confidential and may be subject to legal or other 
> professional privilege. Any confidentiality or privilege is not waived or 
> lost because this e-mail has been sent to you by mistake. If you have 
> received this transmission in error, please notify HSD on +61 3 9875 5900 
> immediately and destroy all copies of this e-mail. The contents of this email 
> message may not be quoted, copied, reproduced or published in part or in 
> whole, without the written authorisation of HSD.
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]