xref: /freebsd/contrib/mandoc/mandocd.8 (revision 01d4e2149e5566e5d9394913dc9fb032da259e0b)
1*61d06d6bSBaptiste Daroussin.\"	$Id: mandocd.8,v 1.2 2017/03/18 19:56:01 schwarze Exp $
2*61d06d6bSBaptiste Daroussin.\"
3*61d06d6bSBaptiste Daroussin.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4*61d06d6bSBaptiste Daroussin.\"
5*61d06d6bSBaptiste Daroussin.\" Permission to use, copy, modify, and distribute this software for any
6*61d06d6bSBaptiste Daroussin.\" purpose with or without fee is hereby granted, provided that the above
7*61d06d6bSBaptiste Daroussin.\" copyright notice and this permission notice appear in all copies.
8*61d06d6bSBaptiste Daroussin.\"
9*61d06d6bSBaptiste Daroussin.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*61d06d6bSBaptiste Daroussin.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*61d06d6bSBaptiste Daroussin.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*61d06d6bSBaptiste Daroussin.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*61d06d6bSBaptiste Daroussin.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*61d06d6bSBaptiste Daroussin.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*61d06d6bSBaptiste Daroussin.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*61d06d6bSBaptiste Daroussin.\"
17*61d06d6bSBaptiste Daroussin.Dd $Mdocdate: March 18 2017 $
18*61d06d6bSBaptiste Daroussin.Dt MANDOCD 8
19*61d06d6bSBaptiste Daroussin.Os
20*61d06d6bSBaptiste Daroussin.Sh NAME
21*61d06d6bSBaptiste Daroussin.Nm mandocd
22*61d06d6bSBaptiste Daroussin.Nd server process to format manual pages in batch mode
23*61d06d6bSBaptiste Daroussin.Sh SYNOPSIS
24*61d06d6bSBaptiste Daroussin.Nm mandocd
25*61d06d6bSBaptiste Daroussin.Op Fl I Cm os Ns = Ns Ar name
26*61d06d6bSBaptiste Daroussin.Op Fl T Ar output
27*61d06d6bSBaptiste Daroussin.Ar socket_fd
28*61d06d6bSBaptiste Daroussin.Sh DESCRIPTION
29*61d06d6bSBaptiste DaroussinThe
30*61d06d6bSBaptiste Daroussin.Nm
31*61d06d6bSBaptiste Daroussinutility formats many manual pages without requiring
32*61d06d6bSBaptiste Daroussin.Xr fork 2
33*61d06d6bSBaptiste Daroussinand
34*61d06d6bSBaptiste Daroussin.Xr exec 3
35*61d06d6bSBaptiste Daroussinoverhead in between.
36*61d06d6bSBaptiste DaroussinIt does not require listing all the manuals to be formatted on the
37*61d06d6bSBaptiste Daroussincommand line, and it supports writing each formatted manual to its
38*61d06d6bSBaptiste Daroussinown file descriptor.
39*61d06d6bSBaptiste Daroussin.Pp
40*61d06d6bSBaptiste DaroussinThis server requires that a connected UNIX domain
41*61d06d6bSBaptiste Daroussin.Xr socket 2
42*61d06d6bSBaptiste Daroussinis already present at
43*61d06d6bSBaptiste Daroussin.Xr exec 3
44*61d06d6bSBaptiste Daroussintime.
45*61d06d6bSBaptiste DaroussinConsequently, it cannot be started from the
46*61d06d6bSBaptiste Daroussin.Xr sh 1
47*61d06d6bSBaptiste Daroussincommand line because the shell cannot supply such a socket.
48*61d06d6bSBaptiste DaroussinTypically, the socket is created by the parent process using
49*61d06d6bSBaptiste Daroussin.Xr socketpair 2
50*61d06d6bSBaptiste Daroussinbefore calling
51*61d06d6bSBaptiste Daroussin.Xr fork 2
52*61d06d6bSBaptiste Daroussinand
53*61d06d6bSBaptiste Daroussin.Xr exec 3
54*61d06d6bSBaptiste Daroussinon
55*61d06d6bSBaptiste Daroussin.Nm .
56*61d06d6bSBaptiste DaroussinThe parent process will pass the file descriptor number as an argument to
57*61d06d6bSBaptiste Daroussin.Xr exec 3 ,
58*61d06d6bSBaptiste Daroussinformatted as a decimal ASCII-encoded integer.
59*61d06d6bSBaptiste DaroussinSee
60*61d06d6bSBaptiste Daroussin.Xr catman 8
61*61d06d6bSBaptiste Daroussinfor a typical implementation of a parent process.
62*61d06d6bSBaptiste Daroussin.Pp
63*61d06d6bSBaptiste Daroussin.Nm
64*61d06d6bSBaptiste Daroussinloops reading one-byte messages with
65*61d06d6bSBaptiste Daroussin.Xr recvmsg 2
66*61d06d6bSBaptiste Daroussinfrom the file descriptor number
67*61d06d6bSBaptiste Daroussin.Ar socket_fd .
68*61d06d6bSBaptiste DaroussinIt ignores the byte read and only uses the out-of-band auxiliary
69*61d06d6bSBaptiste Daroussin.Vt struct cmsghdr
70*61d06d6bSBaptiste Daroussincontrol data, typically supplied by the calling process using
71*61d06d6bSBaptiste Daroussin.Xr CMSG_FIRSTHDR 3 .
72*61d06d6bSBaptiste DaroussinThe parent process is expected to pass three file descriptors
73*61d06d6bSBaptiste Daroussinwith each dummy byte.
74*61d06d6bSBaptiste DaroussinThe first one is used for
75*61d06d6bSBaptiste Daroussin.Xr mdoc 7
76*61d06d6bSBaptiste Daroussinor
77*61d06d6bSBaptiste Daroussin.Xr man 7
78*61d06d6bSBaptiste Daroussininput, the second one for formatted output, and the third one
79*61d06d6bSBaptiste Daroussinfor error output.
80*61d06d6bSBaptiste Daroussin.Pp
81*61d06d6bSBaptiste DaroussinThe options are as follows:
82*61d06d6bSBaptiste Daroussin.Bl -tag -width Ds
83*61d06d6bSBaptiste Daroussin.It Fl I Cm os Ns = Ns Ar name
84*61d06d6bSBaptiste DaroussinOverride the default operating system
85*61d06d6bSBaptiste Daroussin.Ar name
86*61d06d6bSBaptiste Daroussinfor the
87*61d06d6bSBaptiste Daroussin.Xr mdoc 7
88*61d06d6bSBaptiste Daroussin.Ic \&Os
89*61d06d6bSBaptiste Daroussinand for the
90*61d06d6bSBaptiste Daroussin.Xr man 7
91*61d06d6bSBaptiste Daroussin.Ic TH
92*61d06d6bSBaptiste Daroussinmacro.
93*61d06d6bSBaptiste Daroussin.It Fl T Ar output
94*61d06d6bSBaptiste DaroussinOutput format.
95*61d06d6bSBaptiste DaroussinThe
96*61d06d6bSBaptiste Daroussin.Ar output
97*61d06d6bSBaptiste Daroussinargument can be
98*61d06d6bSBaptiste Daroussin.Cm ascii ,
99*61d06d6bSBaptiste Daroussin.Cm utf8 ,
100*61d06d6bSBaptiste Daroussinor
101*61d06d6bSBaptiste Daroussin.Cm html ;
102*61d06d6bSBaptiste Daroussinsee
103*61d06d6bSBaptiste Daroussin.Xr mandoc 1 .
104*61d06d6bSBaptiste DaroussinIn
105*61d06d6bSBaptiste Daroussin.Cm html
106*61d06d6bSBaptiste Daroussinoutput mode, the
107*61d06d6bSBaptiste Daroussin.Cm fragment
108*61d06d6bSBaptiste Daroussinoutput option is implied.
109*61d06d6bSBaptiste DaroussinOther output options are not supported.
110*61d06d6bSBaptiste Daroussin.El
111*61d06d6bSBaptiste Daroussin.Pp
112*61d06d6bSBaptiste DaroussinAfter exhausting one input file descriptor, all three file descriptors
113*61d06d6bSBaptiste Daroussinare closed before reading the next dummy byte and control message.
114*61d06d6bSBaptiste Daroussin.Pp
115*61d06d6bSBaptiste DaroussinWhen a zero-byte message is read, when the
116*61d06d6bSBaptiste Daroussin.Ar socket_fd
117*61d06d6bSBaptiste Daroussinis closed by the parent process,
118*61d06d6bSBaptiste Daroussinor when an error occurs,
119*61d06d6bSBaptiste Daroussin.Nm
120*61d06d6bSBaptiste Daroussinexits.
121*61d06d6bSBaptiste Daroussin.Sh EXIT STATUS
122*61d06d6bSBaptiste Daroussin.Ex -std
123*61d06d6bSBaptiste Daroussin.Pp
124*61d06d6bSBaptiste DaroussinA zero-byte message or a closed
125*61d06d6bSBaptiste Daroussin.Ar socket_fd
126*61d06d6bSBaptiste Daroussinis considered success.
127*61d06d6bSBaptiste DaroussinPossible errors include:
128*61d06d6bSBaptiste Daroussin.Bl -bullet
129*61d06d6bSBaptiste Daroussin.It
130*61d06d6bSBaptiste Daroussinmissing, invalid, or excessive
131*61d06d6bSBaptiste Daroussin.Xr exec 3
132*61d06d6bSBaptiste Daroussinarguments
133*61d06d6bSBaptiste Daroussin.It
134*61d06d6bSBaptiste Daroussin.Xr recvmsg 2
135*61d06d6bSBaptiste Daroussinfailure, for example due to
136*61d06d6bSBaptiste Daroussin.Er EMSGSIZE
137*61d06d6bSBaptiste Daroussin.It
138*61d06d6bSBaptiste Daroussinmissing or unexpected control data, in particular a
139*61d06d6bSBaptiste Daroussin.Fa cmsg_level
140*61d06d6bSBaptiste Daroussinin the
141*61d06d6bSBaptiste Daroussin.Vt struct cmsghdr
142*61d06d6bSBaptiste Daroussinthat differs from
143*61d06d6bSBaptiste Daroussin.Dv SOL_SOCKET ,
144*61d06d6bSBaptiste Daroussina
145*61d06d6bSBaptiste Daroussin.Fa cmsg_type
146*61d06d6bSBaptiste Daroussinthat differs from
147*61d06d6bSBaptiste Daroussin.Dv SCM_RIGHTS ,
148*61d06d6bSBaptiste Daroussinor a
149*61d06d6bSBaptiste Daroussin.Fa cmsg_len
150*61d06d6bSBaptiste Daroussinthat is not three times the size of an
151*61d06d6bSBaptiste Daroussin.Vt int
152*61d06d6bSBaptiste Daroussin.It
153*61d06d6bSBaptiste Daroussininvalid file descriptors passed in the
154*61d06d6bSBaptiste Daroussin.Xr CMSG_DATA 3
155*61d06d6bSBaptiste Daroussin.It
156*61d06d6bSBaptiste Daroussinresource exhaustion, in particular
157*61d06d6bSBaptiste Daroussin.Xr dup 2
158*61d06d6bSBaptiste Daroussinor
159*61d06d6bSBaptiste Daroussin.Xr malloc 3
160*61d06d6bSBaptiste Daroussinfailure
161*61d06d6bSBaptiste Daroussin.El
162*61d06d6bSBaptiste Daroussin.Pp
163*61d06d6bSBaptiste DaroussinExcept for memory exhaustion and similar system-level failures,
164*61d06d6bSBaptiste Daroussinparsing and formatting errors do not cause
165*61d06d6bSBaptiste Daroussin.Nm
166*61d06d6bSBaptiste Daroussinto return an error exit status.
167*61d06d6bSBaptiste DaroussinEven after severe parsing errors,
168*61d06d6bSBaptiste Daroussin.Nm
169*61d06d6bSBaptiste Daroussinwill simply accept and process the next input file descriptor.
170*61d06d6bSBaptiste Daroussin.Sh SEE ALSO
171*61d06d6bSBaptiste Daroussin.Xr mandoc 1 ,
172*61d06d6bSBaptiste Daroussin.Xr mandoc 3 ,
173*61d06d6bSBaptiste Daroussin.Xr catman 8
174*61d06d6bSBaptiste Daroussin.Sh HISTORY
175*61d06d6bSBaptiste DaroussinThe
176*61d06d6bSBaptiste Daroussin.Nm
177*61d06d6bSBaptiste Daroussinutility appeared in version 1.14.1 or the
178*61d06d6bSBaptiste Daroussin.Sy mandoc
179*61d06d6bSBaptiste Daroussintoolkit.
180*61d06d6bSBaptiste Daroussin.Sh AUTHORS
181*61d06d6bSBaptiste Daroussin.An -nosplit
182*61d06d6bSBaptiste DaroussinThe concept was designed and implemented by
183*61d06d6bSBaptiste Daroussin.An Michael Stapelberg Aq Mt stapelberg@debian.org .
184*61d06d6bSBaptiste DaroussinThe
185*61d06d6bSBaptiste Daroussin.Xr mandoc 3
186*61d06d6bSBaptiste Daroussinglue needed to make it a stand-alone process was added by
187*61d06d6bSBaptiste Daroussin.An Ingo Schwarze Aq Mt schwarze@openbsd.org .
188*61d06d6bSBaptiste Daroussin.Sh CAVEATS
189*61d06d6bSBaptiste DaroussinIf the parsed manual pages contain
190*61d06d6bSBaptiste Daroussin.Xr roff 7
191*61d06d6bSBaptiste Daroussin.Pf . Ic so
192*61d06d6bSBaptiste Daroussinrequests,
193*61d06d6bSBaptiste Daroussin.Nm
194*61d06d6bSBaptiste Daroussinneeds to be started with the current working directory set to the
195*61d06d6bSBaptiste Daroussinroot of the manual page tree.
196*61d06d6bSBaptiste DaroussinAvoid starting it in directories that contain secret files in any
197*61d06d6bSBaptiste Daroussinsubdirectories, in particular in the user starting it has read
198*61d06d6bSBaptiste Daroussinaccess to these secret files.
199