Cool, I will stick with my hack for the moment and keep an eye svn for the response callbacks.
Regards, Denis -----Original Message----- From: libmicrohttpd-bounces+denis.dowling=hsd.com...@gnu.org [mailto:libmicrohttpd-bounces+denis.dowling=hsd.com...@gnu.org] On Behalf Of Christian Grothoff Sent: Thursday, 4 June 2015 3:33 PM To: libmicrohttpd@gnu.org Subject: Re: [libmicrohttpd] MHD_create_response_from_fd using a pipe 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: libmicrohttpd-bounces+denis.dowling=hsd.com...@gnu.org > [mailto:libmicrohttpd-bounces+denis.dowling=hsd.com...@gnu.org] On > Behalf Of Christian Grothoff > Sent: Wednesday, 3 June 2015 3:58 PM > To: libmicrohttpd@gnu.org > 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. > ________________________________ 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.