MANDOCD(8)
π MANDOCD π
okay bestie, welcome to mandocd from the System Manager's Manual section 8 (that's the system administration girlies π
) β she's a server process, and she's here to format manual pages in batch mode, no cap.
β¨ SYNOPSIS β¨
mandocd [-I os=name] [-T output] socket_fd
periodt. that's the whole summoning ritual.
π¦ DESCRIPTION π¦
so mandocd formats so many manual pages for you, and the iconic part is she does it without needing fork(2) and exec(3) overhead in between every single one. main character efficiency honestly. she also does not need you to list all the manuals to be formatted on the command line, and she supports writing each formatted manual to its own file descriptor. queen behavior π₯
big caveat alert: this server requires that a connected UNIX domainsocket(2)is already present atexec(3)time.
and because of that, she literally cannot be started from the sh(1) command line β the shell just can't supply a socket like that. sorry bestie π
so how do people do it? typically the parent process creates the socket using socketpair(2) before calling fork(2) and exec(3) on mandocd. the parent then passes the file descriptor number as an argument to exec(3), formatted as a decimal ASCII-encoded integer. that's your socket_fd β¨ if you want to see a typical implementation of a parent process, go look at catman(8). iykyk.
here's the loop she lives in, and it's honestly such a vibe:
mandocdloops reading one-byte messages withrecvmsg(2)from the file descriptor numbersocket_fd.- she ignores the byte read entirely (not her business, she's above it πΈ) and only uses the out-of-band auxiliary
struct cmsghdrcontrol data, typically supplied by the calling process usingCMSG_FIRSTHDR(3). - the parent process is expected to pass three file descriptors with each dummy byte:
the options are as follows (yes we're doing the whole list, obsessed):
-I os=nameβ override the default operating system name for themdoc(7)Osmacro and for theman(7)THmacro. π-T outputβ output format. theoutputargument can beascii,utf8, orhtml; seemandoc(1). inhtmloutput mode, the fragment output option is implied. other output options are not supported. π«
after exhausting one input file descriptor, all three file descriptors are closed before reading the next dummy byte and control message. so clean. so tidy. we stan a girl who cleans up after herself π§
and then β when a zero-byte message is read, when the socket_fd is closed by the parent process, or when an error occurs β mandocd exits. bye bestie π
π EXIT STATUS π
mandocdexits0on success, and>0if an error occurs.
a zero-byte message or a closed socket_fd is considered success π. a win is a win.
possible errors include (get comfy, this is the vibe check):
- missing, invalid, or excessive
exec(3)arguments recvmsg(2)failure, for example due toEMSGSIZE- missing or unexpected control data, in particular a
cmsg_levelin thestruct cmsghdrthat differs fromSOL_SOCKET, acmsg_typethat differs fromSCM_RIGHTS, or acmsg_lenthat is not three times the size of anint - invalid file descriptors passed in the
CMSG_DATA(3) - resource exhaustion, in particular
dup(2)ormalloc(3)failure
but here's the part that lowkey changes your whole day: except for memory exhaustion and similar system-level failures, parsing and formatting errors do NOT cause mandocd to return an error exit status. even after severe parsing errors, mandocd will simply accept and process the next input file descriptor. she is unbothered. she is booked and busy. she moves on π
π SEE ALSO π
β HISTORY β
the mandocd utility appeared in version 1.14.1 or the mandoc toolkit. (that's literally what the page says, bestie, "or" and all β i just deliver the facts π
)
π AUTHORS π
- the concept was designed and implemented by Michael Stapelberg
<stapelberg@debian.org>. π«Ά - the
mandoc(3)glue needed to make it a stand-alone process was added by Ingo Schwarze<schwarze@openbsd.org>. β¨
π₯ CAVEATS π₯
read this one fr fr, it's giving security warning:
if the parsed manual pages contain roff(7) .so requests, mandocd needs to be started with the current working directory set to the root of the manual page tree. π³
and avoid starting it in directories that contain secret files in any subdirectories β in particular when the user starting it has read access to these secret files. like, don't do it. protect the secrets. π«π
kisses, this was MANDOCD(8) from the System Manager's Manual, brought to you by Debian on March 18, 2017 β slay, stay formatted, and never leave your socket unpaired πππ¦
π¦ where this page comes from
- arch rolling: mandoc 1.14.6-5 Β· ISC
- debian trixie: mandoc 1.14.6-4 Β· ISC
- ubuntu questing: mandoc 1.14.6-4
- ubuntu resolute: mandoc 1.14.6-4build1 Β· ISC
- ubuntu stonking: mandoc 1.14.6-4build1 Β· ISC
- Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms