---
name: "mandocd"
section: "8"
platform: "linux"
package: "mandoc"
version: "1.14.6-5"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mandocd"
---

# mandocd(8)

server process to format manual pages in batch mode

## NAME

**mandocd** – server process to format manual pages in batch mode

## SYNOPSIS

**mandocd** \[**-I** **os**=*name*\] \[**-T** *output*\] *socket\_fd*

## DESCRIPTION

The **mandocd** utility formats many manual pages without requiring [fork(2)](/fork/2.md) and [exec(3)](/exec/3.md) overhead in between. It does not require listing all the manuals to be formatted on the command line, and it supports writing each formatted manual to its own file descriptor.

This server requires that a connected UNIX domain [socket(2)](/socket/2.md) is already present at [exec(3)](/exec/3.md) time. Consequently, it cannot be started from the [sh(1)](/sh/1.md) command line because the shell cannot supply such a socket. Typically, the socket is created by the parent process using [socketpair(2)](/socketpair/2.md) before calling [fork(2)](/fork/2.md) and [exec(3)](/exec/3.md) on **mandocd**. The parent process will pass the file descriptor number as an argument to [exec(3)](/exec/3.md), formatted as a decimal ASCII-encoded integer. See [catman(8)](/catman/8.md) for a typical implementation of a parent process.

**mandocd** loops reading one-byte messages with [recvmsg(2)](/recvmsg/2.md) from the file descriptor number *socket\_fd*. It ignores the byte read and only uses the out-of-band auxiliary *struct* *cmsghdr* control data, typically supplied by the calling process using [CMSG\_FIRSTHDR(3)](/CMSG_FIRSTHDR/3.md). The parent process is expected to pass three file descriptors with each dummy byte. The first one is used for [mdoc(7)](/mdoc/7.md) or [man(7)](/man/7.md) input, the second one for formatted output, and the third one for error output.

The options are as follows:

- **-I** **os**=*name*

  Override the default operating system *name* for the [mdoc(7)](/mdoc/7.md) **Os** and for the [man(7)](/man/7.md) **TH** macro.

- **-T** *output*

  Output format. The *output* argument can be **ascii**, **utf8**, or **html**; see [mandoc(1)](/mandoc/1.md). In **html** output 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.

When a zero-byte message is read, when the *socket\_fd* is closed by the parent process, or when an error occurs, **mandocd** exits.

## EXIT STATUS

The **mandocd** utility exits 0 on success, and \>0 if an error occurs.

A zero-byte message or a closed *socket\_fd* is considered success. Possible errors include:

- missing, invalid, or excessive [exec(3)](/exec/3.md) arguments

- [recvmsg(2)](/recvmsg/2.md) failure, for example due to EMSGSIZE

- missing or unexpected control data, in particular a *cmsg\_level* in the *struct* *cmsghdr* that differs from SOL\_SOCKET, a *cmsg\_type* that differs from SCM\_RIGHTS, or a *cmsg\_len* that is not three times the size of an *int*

- invalid file descriptors passed in the [CMSG\_DATA(3)](/CMSG_DATA/3.md)

- resource exhaustion, in particular [dup(2)](/dup/2.md) or [malloc(3)](/malloc/3.md) failure

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.

## SEE ALSO

[mandoc(1)](/mandoc/1.md), [mandoc(3)](/mandoc/3.md), [catman(8)](/catman/8.md)

## HISTORY

The **mandocd** utility appeared in version 1.14.1 or the **mandoc** toolkit.

## AUTHORS

The concept was designed and implemented by Michael Stapelberg ⟨*stapelberg@debian.org*⟩. The [mandoc(3)](/mandoc/3.md) glue needed to make it a stand-alone process was added by Ingo Schwarze ⟨*schwarze@openbsd.org*⟩.

## CAVEATS

If the parsed manual pages contain [roff(7)](/roff/7.md) .**so** requests, **mandocd** needs to be started with the current working directory set to the root of the manual page tree. Avoid starting it in directories that contain secret files in any subdirectories, in particular in the user starting it has read access to these secret files.
