KHTTP_FREE(3)
π 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 whilestdout,stderr, andstdinare 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
- Copyright (c) 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms