KHTTP_FREE(3)

πŸ“¦
version 1.0.1 Β· 2 versions
, in alpine 3.24

πŸŽ€ khttp_free(3) β€” like, the libkcgi manual page, bestie πŸŽ€

Okay so this is the khttp_free page out of the Library Functions Manual, and honestly? It's a whole vibe. Grab a strawberry drink πŸ“ and let's get into it.


✨ NAME ✨

khttp_free, khttp_child_free β€” the two functions that free a CGI instance for kcgi. That's it, that's the whole name section, slay πŸ’…

πŸ“š LIBRARY πŸ“š

You're gonna need library β€œlibkcgi”. No cap, that's where these live 🫢

🌸 SYNOPSIS 🌸

Okay so before literally anything works, you gotta pull in these headers, in this exact order, no skipping:

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>

Then the two icons themselves ✨:

void
khttp_free(struct kreq *req);

void
khttp_child_free(struct kreq *req);

πŸ¦‹ DESCRIPTION πŸ¦‹

Bestie, listen. The khttp_free() and khttp_child_free() functions free the resources of req that were allocated by khttp_parse(3) or khttp_fcgi_parse(3) β€” and they flush the HTTP data stream while they're at it πŸ’–. Cleanup queen behavior.

🚨 Main character rule: after you call this function, the members of req should not be used, and you should not call the function again. It's a one-and-done situation, periodt. Use it and let it go 😭

So khttp_child_free() performs the same operations as khttp_free(), but doesn't flush the HTTP data stream. That's the whole difference, iykyk. Because of that, it may be used after invoking fork(2) without confusing the output buffer πŸ”₯. It's giving "same energy, new context."

⚠️ Note, and this one's important: if you're forking within your CGI application, be aware of some caveats. Most web servers will continue to wait while stdout, stderr, and stdin are open to the CGI application. So if you fork a long-running application, you must close out these file descriptors. Not optional, not a vibe, just do it πŸ’€

πŸ‘€ SEE ALSO πŸ‘€

Go read these next, they're literally connected:

πŸ‘‘ AUTHORS πŸ‘‘

The khttp_free() and khttp_child_free() functions were written by Kristaps Dzonsons <kristaps@bsd.lv>. Thank you king, we're obsessed 🫢✨


πŸ’– and that's the page!! πŸ’– Quick sign-off before you go: this one's from the Debian build, stamped $Mdocdate$, and you're reading KHTTP_FREE(3). Now go free your req and live your best life πŸ§šπŸ’œ

πŸ“¦ where this page comes from
  • alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms