xref: /netbsd-src/external/bsd/mdocml/dist/mandocd.8 (revision c9bcef0391a5afc0280459d5c16c26ace267c496)
1*c9bcef03Schristos.\"	Id: mandocd.8,v 1.2 2017/03/18 19:56:01 schwarze Exp
29508192eSchristos.\"
39508192eSchristos.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
49508192eSchristos.\"
59508192eSchristos.\" Permission to use, copy, modify, and distribute this software for any
69508192eSchristos.\" purpose with or without fee is hereby granted, provided that the above
79508192eSchristos.\" copyright notice and this permission notice appear in all copies.
89508192eSchristos.\"
99508192eSchristos.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
109508192eSchristos.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
119508192eSchristos.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
129508192eSchristos.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
139508192eSchristos.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
149508192eSchristos.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
159508192eSchristos.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
169508192eSchristos.\"
17*c9bcef03Schristos.Dd March 18, 2017
189508192eSchristos.Dt MANDOCD 8
199508192eSchristos.Os
209508192eSchristos.Sh NAME
219508192eSchristos.Nm mandocd
229508192eSchristos.Nd server process to format manual pages in batch mode
239508192eSchristos.Sh SYNOPSIS
249508192eSchristos.Nm mandocd
259508192eSchristos.Op Fl I Cm os Ns = Ns Ar name
269508192eSchristos.Op Fl T Ar output
279508192eSchristos.Ar socket_fd
289508192eSchristos.Sh DESCRIPTION
299508192eSchristosThe
309508192eSchristos.Nm
319508192eSchristosutility formats many manual pages without requiring
329508192eSchristos.Xr fork 2
339508192eSchristosand
349508192eSchristos.Xr exec 3
359508192eSchristosoverhead in between.
369508192eSchristosIt does not require listing all the manuals to be formatted on the
379508192eSchristoscommand line, and it supports writing each formatted manual to its
389508192eSchristosown file descriptor.
399508192eSchristos.Pp
409508192eSchristosThis server requires that a connected UNIX domain
419508192eSchristos.Xr socket 2
429508192eSchristosis already present at
439508192eSchristos.Xr exec 3
449508192eSchristostime.
459508192eSchristosConsequently, it cannot be started from the
469508192eSchristos.Xr sh 1
479508192eSchristoscommand line because the shell cannot supply such a socket.
489508192eSchristosTypically, the socket is created by the parent process using
499508192eSchristos.Xr socketpair 2
509508192eSchristosbefore calling
519508192eSchristos.Xr fork 2
529508192eSchristosand
539508192eSchristos.Xr exec 3
549508192eSchristoson
559508192eSchristos.Nm .
569508192eSchristosThe parent process will pass the file descriptor number as an argument to
579508192eSchristos.Xr exec 3 ,
589508192eSchristosformatted as a decimal ASCII-encoded integer.
599508192eSchristosSee
609508192eSchristos.Xr catman 8
619508192eSchristosfor a typical implementation of a parent process.
629508192eSchristos.Pp
639508192eSchristos.Nm
649508192eSchristosloops reading one-byte messages with
659508192eSchristos.Xr recvmsg 2
669508192eSchristosfrom the file descriptor number
679508192eSchristos.Ar socket_fd .
689508192eSchristosIt ignores the byte read and only uses the out-of-band auxiliary
699508192eSchristos.Vt struct cmsghdr
709508192eSchristoscontrol data, typically supplied by the calling process using
719508192eSchristos.Xr CMSG_FIRSTHDR 3 .
729508192eSchristosThe parent process is expected to pass three file descriptors
739508192eSchristoswith each dummy byte.
749508192eSchristosThe first one is used for
759508192eSchristos.Xr mdoc 7
769508192eSchristosor
779508192eSchristos.Xr man 7
789508192eSchristosinput, the second one for formatted output, and the third one
799508192eSchristosfor error output.
809508192eSchristos.Pp
819508192eSchristosThe options are as follows:
829508192eSchristos.Bl -tag -width Ds
839508192eSchristos.It Fl I Cm os Ns = Ns Ar name
849508192eSchristosOverride the default operating system
859508192eSchristos.Ar name
869508192eSchristosfor the
879508192eSchristos.Xr mdoc 7
88*c9bcef03Schristos.Ic \&Os
899508192eSchristosand for the
909508192eSchristos.Xr man 7
919508192eSchristos.Ic TH
929508192eSchristosmacro.
939508192eSchristos.It Fl T Ar output
949508192eSchristosOutput format.
959508192eSchristosThe
969508192eSchristos.Ar output
979508192eSchristosargument can be
989508192eSchristos.Cm ascii ,
999508192eSchristos.Cm utf8 ,
1009508192eSchristosor
1019508192eSchristos.Cm html ;
1029508192eSchristossee
1039508192eSchristos.Xr mandoc 1 .
1049508192eSchristosIn
1059508192eSchristos.Cm html
1069508192eSchristosoutput mode, the
1079508192eSchristos.Cm fragment
1089508192eSchristosoutput option is implied.
1099508192eSchristosOther output options are not supported.
1109508192eSchristos.El
1119508192eSchristos.Pp
1129508192eSchristosAfter exhausting one input file descriptor, all three file descriptors
1139508192eSchristosare closed before reading the next dummy byte and control message.
1149508192eSchristos.Pp
1159508192eSchristosWhen a zero-byte message is read, when the
1169508192eSchristos.Ar socket_fd
1179508192eSchristosis closed by the parent process,
1189508192eSchristosor when an error occurs,
1199508192eSchristos.Nm
1209508192eSchristosexits.
1219508192eSchristos.Sh EXIT STATUS
1229508192eSchristos.Ex -std
1239508192eSchristos.Pp
1249508192eSchristosA zero-byte message or a closed
1259508192eSchristos.Ar socket_fd
1269508192eSchristosis considered success.
1279508192eSchristosPossible errors include:
1289508192eSchristos.Bl -bullet
1299508192eSchristos.It
1309508192eSchristosmissing, invalid, or excessive
1319508192eSchristos.Xr exec 3
1329508192eSchristosarguments
1339508192eSchristos.It
1349508192eSchristos.Xr recvmsg 2
1359508192eSchristosfailure, for example due to
1369508192eSchristos.Er EMSGSIZE
1379508192eSchristos.It
1389508192eSchristosmissing or unexpected control data, in particular a
1399508192eSchristos.Fa cmsg_level
1409508192eSchristosin the
1419508192eSchristos.Vt struct cmsghdr
1429508192eSchristosthat differs from
1439508192eSchristos.Dv SOL_SOCKET ,
1449508192eSchristosa
1459508192eSchristos.Fa cmsg_type
1469508192eSchristosthat differs from
1479508192eSchristos.Dv SCM_RIGHTS ,
1489508192eSchristosor a
1499508192eSchristos.Fa cmsg_len
1509508192eSchristosthat is not three times the size of an
1519508192eSchristos.Vt int
1529508192eSchristos.It
1539508192eSchristosinvalid file descriptors passed in the
1549508192eSchristos.Xr CMSG_DATA 3
1559508192eSchristos.It
1569508192eSchristosresource exhaustion, in particular
1579508192eSchristos.Xr dup 2
1589508192eSchristosor
1599508192eSchristos.Xr malloc 3
1609508192eSchristosfailure
1619508192eSchristos.El
1629508192eSchristos.Pp
1639508192eSchristosExcept for memory exhaustion and similar system-level failures,
1649508192eSchristosparsing and formatting errors do not cause
1659508192eSchristos.Nm
1669508192eSchristosto return an error exit status.
1679508192eSchristosEven after severe parsing errors,
1689508192eSchristos.Nm
1699508192eSchristoswill simply accept and process the next input file descriptor.
1709508192eSchristos.Sh SEE ALSO
1719508192eSchristos.Xr mandoc 1 ,
1729508192eSchristos.Xr mandoc 3 ,
1739508192eSchristos.Xr catman 8
1749508192eSchristos.Sh HISTORY
1759508192eSchristosThe
1769508192eSchristos.Nm
1779508192eSchristosutility appeared in version 1.14.1 or the
1789508192eSchristos.Sy mandoc
1799508192eSchristostoolkit.
1809508192eSchristos.Sh AUTHORS
1819508192eSchristos.An -nosplit
1829508192eSchristosThe concept was designed and implemented by
1839508192eSchristos.An Michael Stapelberg Aq Mt stapelberg@debian.org .
1849508192eSchristosThe
1859508192eSchristos.Xr mandoc 3
1869508192eSchristosglue needed to make it a stand-alone process was added by
1879508192eSchristos.An Ingo Schwarze Aq Mt schwarze@openbsd.org .
1889508192eSchristos.Sh CAVEATS
1899508192eSchristosIf the parsed manual pages contain
1909508192eSchristos.Xr roff 7
1919508192eSchristos.Pf . Ic so
1929508192eSchristosrequests,
1939508192eSchristos.Nm
1949508192eSchristosneeds to be started with the current working directory set to the
1959508192eSchristosroot of the manual page tree.
1969508192eSchristosAvoid starting it in directories that contain secret files in any
1979508192eSchristossubdirectories, in particular in the user starting it has read
1989508192eSchristosaccess to these secret files.
199