KHTTP_FCGI_INIT(3)
β¨ NAME β¨
okay so bestie, this is KHTTP_FCGI_INIT(3) from the Library Functions Manual, and it's all about khttp_fcgi_init and khttp_fcgi_initx β the functions that initialise a FastCGI context for kcgi(3). π
π LIBRARY
You're working with library βlibkcgiβ. π
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
enum kcgi_err
khttp_fcgi_init(struct kfcgi **fcgi, const struct kvalid *keys,
size_t keysz, const char *const *pages, size_t pagesz,
size_t defpage);
enum kcgi_err
khttp_fcgi_initx(struct kreq **fcgi, const char *const *mimes,
size_t mimemax, const struct kvalid *keys, size_t keysz,
const struct kmimemap *mimemap, size_t defmime,
const char *const *pages, size_t pagesz, size_t defpage, void *arg,
void (*argfree)(void *arg), unsigned int debugging,
const struct kopts *opts);
π DESCRIPTION π
The khttp_fcgi_init() and khttp_fcgi_initx() functions initialise a FastCGI context for kcgi(3). These functions will only work if invoked as FastCGI servers β for example, kfcgi(8). They should be called as early as possible in the life-span of a FastCGI application, preferably directly after initialisation. Like, right away, bestie. β¨
The collective arguments are defined in khttp_parse(3). Function arguments are not copied: all pointers are passed by reference and used in later invocations of khttp_fcgi_parse(3).
The first form, khttp_fgci_init(), is for applications using the system-recognised MIME types. This should work well enough for most applications. It is equivalent to invoking the second form, khttp_fcgi_initx(), as follows:
khttp_fcgi_initx(fcgi, kmimetypes, KMIME__MAX,
keys, keysz, ksuffixmap, KMIME_TEXT_HTML,
pages, pagesz, defpage, NULL, NULL, 0, NULL);
After invocation with a return value of KCGI_OK, the fcgi pointer is filled in (and must later be freed with khttp_fcgi_free(3)) and the khttp_fcgi_parse(3) and khttp_fcgi_parsex(3) functions may be invoked. π«Ά
π Note: in accordance with the FastCGI specification,khttp_fcgi_init()andkhttp_fcgi_initx()will install signal handlers forSIGTERM. These should not be changed by the calling application, but are not prohibited from doing so. The consequences are that a server wishing to halt the application must useSIGKILLinstead of the FastCGI-specifiedSIGTERMand suffer the consequences of not properly exiting the parse loop.
π§ RETURN VALUES π§
khttp_fcgi_init() and khttp_fcgi_initx() return an error code:
KCGI_OKβ Success (not an error). slay.KCGI_ENOMEMβ Memory failure. This can occur in many places: spawning a child, allocating memory, creating sockets, etc.KCGI_ENFILEβ Could not allocate file descriptors.KCGI_EAGAINβ Could not spawn a child.KCGI_SYSTEMβ Opaque operating system error.KCGI_HUPβ Hangup: the function was not invoked in a FastCGI context.
π¨ On failure, the calling application should terminate as soon as possible. no cap.
π¦ SEE ALSO π¦
π AUTHORS π
The khttp_fcgi_init() and khttp_fcgi_initx() functions were written by Kristaps Dzonsons <kristaps@bsd.lv>. π
okay that's the whole vibe check, bestie β this page comes from Debian, with the date slot showing $Mdocdate$, and you can absolutely think of that as the little timestamp bow on top. πππ
π¦ where this page comes from
- alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
- Copyright (c) 2015, 2016 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