This file is indexed.

/usr/share/doc/libbobcat4-dev/man/process.3.html is in libbobcat-dev 4.04.00-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::Process</title>
<style type="text/css">
    figure {text-align: center;}
    img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title">FBB::Process</h1>
<h2 id="author">libbobcat-dev_4.04.00-x.tar.gz</h2>
<h2 id="date">2005-2016</h2>

<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<style type="text/css">
    figure {text-align: center;}
    img {vertical-align: center;}
    figure {text-align: center;}
    img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title"></h1>

<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::Process(3bobcat)</title>
<style type="text/css">
    figure {text-align: center;}
    img {vertical-align: center;}
    figure {text-align: center;}
    img {vertical-align: center;}
    figure {text-align: center;}
    img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title">FBB::Process(3bobcat)</h1>
<h2 id="author">libbobcat-dev_4.04.00-x.tar.gz Running Child Processes</h2>
<h2 id="date">2005-2016</h2>


<p>
<h2 >NAME</h2>FBB::Process - Runs external programs
<p>
<h2 >SYNOPSIS</h2>
    <strong >#include &lt;bobcat/process&gt;</strong><br/>
    Linking option: <em >-lbobcat</em> 
<p>
<h2 >DESCRIPTION</h2>
    The <strong >FBB::Process</strong> class offers an extensive interface to calling
external programs and/or scripts from a <strong >C++</strong> program (so-called
<em >child-processes</em>). The class offers an easy to use, stream-based interface
to the standard input, standard output and standard error streams of child
processes.
<p>
Objects of the <em >class Process</em> use standard process-executing functions,
like members of the <strong >execl</strong>(1) family or <strong >sh</strong>(1) to execute child
processes. Thus, child processes can be executable programs or
<em >shell-scripts</em>.
<p>
The standard input, output and error streams of child processes may
be accessed through their <em >Process</em> parent objects. Input expected by child
processes may be inserted by <em >Process</em> objects, and output generated by
child processes may be extracted from <em >Process</em> objects. 
<p>
When using (output) redirection with the <em >USE_SHELL</em> path specification (see
below for the path and IOMode specifications), the <em >IGNORE_COUT IOMode</em> (and
possibly <em >IGNORE_CERR</em>) should normally be specified (see also this
man-page's <strong >PIPING</strong> section).
<p>
<em >Process</em> objects may repeatedly be used to execute the same or different
child processes. Before the next child process is started, the <em >Process</em>
object first terminates its currently active child process. Alternatively, a
currently active child process is automatically ended if the <em >Process</em>
object goes out of scope, if its <em >stop</em> or <em >eoi</em> (end-of-information)
member is called, or if the <em >eoi</em> manipulator is inserted into the
<em >Process</em> object.
<p>
Programs to be called as child processes may be specified at <em >Process's</em>
constructor-time or through <em >Process's setCommand</em> member. <em >Process</em>
constructors (or <em >Process set</em>-members) never start child processes. Child
processes are started through <em >start</em> members or the assignment operator.
<p>
Child processes may receive information at their standard input streams
through information inserted into <em >Process</em> objects. In these cases the
<em >Process</em> objects must inform their child processes that they have received
all input. For this the <em >close</em> or <em >eoi</em> member or the <em >eoi</em> manipulator
can be used. After calling the <em >close</em> member, the <em >waitForChild</em> member
should be called as well. This is not necessary if either the <em >eoi</em> member
or the <em >eoi</em> manipulator is used.
<p>
If <em >waitForChild</em> is not called (but information sent to the child which
could not be fully processed by the child process in case the child process
terminated as a result of the <em >Process</em> object going out of scope), then the
operating system issues a <em >Broken pipe</em> message, indicating that information
in a pipe was lost.
<p>
Arguments passed to child processes may be surrounded by double
or single quotes. Arguments surrounded by double quotes have their double
quotes removed, while interpreting any escape-sequences that may have been
used within. Arguments surrounded by single quotes have their single quotes
removed, while accepting their contents as-is. In addition unquoted
escape-sequences may be specified: those escape sequences are evaluated and
replaced by their intended characters (e.g., <em >\100</em> is converted to <em >@</em>).
<p>
A full command specification may be surrounded by backtics
(<em >`</em>-characters). These backtick characters are removed by the <em >Process</em>
object when the command is started.
<p>
Child processes may be allowed a limited amount of time (in seconds) to
complete. By default no time limit is imposed upon child processes.
<p>
By default the standard input, output and error streams of child processes are
accessed through their <em >Process</em> parent processes: information inserted into
the <em >Process</em> object is forwarded to the child process's standard input
stream, information sent by the child process to its standard output stream
can be extracted from its parent <em >Process</em> object, and information sent by
the child process to its standard error stream may be obtained through
<em >Process's childErrStream</em> member.
<p>
If the parent and child processes have agreed on some communication process,
then information may alternatingly be sent to and received from the child
process through the <em >Process's ostream</em> and <em >istream</em>
facilities. Alternatively, unspecified amounts of information written by child
processes may be processed by separate threads (cf. this manual page's
<strong >EXAMPLES</strong> section).
<p>
<h2 >NAMESPACE</h2>
    <strong >FBB</strong><br/>
    All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace <strong >FBB</strong>.
<p>
<h2 >INHERITS FROM</h2>
    <strong >FBB::Fork</strong>(3bobcat) (private), <br/>
    <strong >FBB:IOStream</strong>(3bobcat)
    <strong >FBB:ProcessEnums</strong>
<p>
The <em >struct ProcessEnums</em> defines enumerations and support functions which
are used by several classes. Its enumerations are documented below; there is
no separate <strong >ProcessEnums</strong> man-page.
<p>
<h2 >ENUMERATIONS</h2>
<p>
<strong >enum ProcessType</strong>:<br/>
<p>
The <strong >enum ProcessType</strong> defines how a child process is started or
located. Its values are specified at constructor-time or through the
<em >setProcessType</em> member. This enumeration defines the following symbolic
constants:
        <ul>
        <li> <strong >NO_PATH</strong>:<br/>
           The program specified as child process is started as specified,
            without searching the elements of the <em >PATH</em> environment
            variable.
        <li> <strong >USE_PATH</strong>:<br/>
           The elements of the <em >PATH</em> environment variable are used when
            locating the program specified as child process.
        <li> <strong >USE_SHELL</strong>:<br/>
           The program specified as child process is called using <em >/bin/sh
            -c</em>. When (output) redirection is used with the specified command
            the <em >IGNORE_COUT IOMode</em> (and possibly also the <em >IGNORE_CERR
            IOMode</em>) should be specified.
        </ul>
<p>
<strong >enum IOMode</strong>:<br/>
<p>
Values of the <em >enum IOMode</em> are used to define which of the child
process's standard streams can be accessed through the <em >Process</em> object. Its
symbolic constants may be combined using the <em >bit_or</em> operator. By default
<em >CIN | COUT | CERR</em> is used (see below).
<p>
The following symbolic constants are available:
        <ul>
        <li> <strong >ALL</strong>:<br/>
           Shortcut for <strong >CIN | COUT | CERR</strong>.
        <li> <strong >CIN</strong>:<br/>
           Information inserted into the <em >Process</em> object is forwarded to
            its child process.  If this is not required then <em >CIN</em> should
            not be specified.
        <li> <strong >CERR</strong>:<br/>
           Information written by the child process to its standard error
            stream is accessible through <em >Process's childErrStream</em> member.
            If this is not required then <em >CERR</em> should not be specified.
        <li> <strong >COUT</strong>:<br/>
           Information written by the child process to its standard output
            stream may be directly be extracted from the <em >Process</em> object,
            or from its <em >childOutStream</em> member.  If this is not required
            then <em >CERR</em> should not be specified.
        <li> <strong >DIRECT</strong>:<br/> 
           When starting a child process (see below at the member <em >start</em>)
            the current process (i.e., the program defining the <em >Process</em>
            object) is replaced by the child process, inheriting the current
            process's standard input and output streams. If this mode is
            specified in combination with any other <em >IOMode</em> (except for
            <em >STD</em>, see below) an <em >std::invalid_argument</em> exception is
            thrown.
        <li> <strong >IGNORE_CERR</strong>:<br/>
           Information written by the child process to its standard error
            stream is sent to <em >/dev/null</em>. An <em >std::invalid_argument</em>
            exception is thrown if this mode is specified in combination with
            <strong >DIRECT, CERR</strong> and/or <strong >MERGE_COUT_CERR</strong>.
        <li> <strong >IGNORE_COUT</strong>:<br/>
           Information written by the child process to its standard output
            stream is sent to <em >/dev/null</em>. An <em >std::invalid_argument</em>
            exception is thrown if this mode is specified in combination with
            <strong >COUT, DIRECT</strong> and/or <strong >MERGE_COUT_CERR</strong>.
        <li> <strong >IGNORE_COUT_CERR</strong>:<br/>
           Shortcut for <em >IGNORE_CERR | IGNORE_COUT</em>.
        <li> <strong >MERGE_COUT_CERR</strong>:<br/>
           Information extracted from the <em >Process</em> object is written by the
            child process to its standard output and standard error streams.
            An <em >std::invalid_argument</em> exception is thrown if this mode is
            specified in combination with <strong >COUT, CERR, DIRECT, IGNORE_COUT</strong>
            or <em >IGNORE_CERR</em>.
        <li> <strong >NONE</strong>:<br/>
           The <em >Process</em> object does not extract information from or insert
            information into the standard streams of its child process. The
            child process reads the same standard input stream and writes the
            same standard output streams as its parent <em >Process</em>
            object. When this mode is specified in combination with other
            <em >IOMode</em> values it is silently ignored.  
        </ul>
<p>
<strong >enum ChildOutput</strong>:<br/>
       The <em >ChildOutput</em> enumeration defines values returned by the
<em >available</em> member (see below) indicating to which standard stream the
child process has written information.  This enumeration defines the following
values:
        <ul>
        <li> <strong >NOTHING_AVAILABLE</strong>:<br/>
           The child process did not (yet) write any information to its
            standard streams;
        <li> <strong >CHILD_COUT</strong>:<br/>
           The child process wrote information to its standard output
            stream which is waiting for extraction.
        <li> <strong >CHILD_CERR</strong>:<br/>
           The child process wrote information to its standard error stream
            which is waiting for extraction.
        </ul>
    The latter two values may be combined using the <em >bit_or</em> operator. The
<em >bit_and</em> operator,returning a <em >bool</em> value can be used to test whether
information on a specific output stream is available.
<p>
<h2 >PROCESS PARAMETERS</h2>
<p>
Four process parameters may be specified: the sizes of the stream buffers
which are used when communicating with child processes; to specify which of
the standard streams of child processes can be accessed from the <em >Process</em>
object combinations of <em >IOMode</em> values are used; to specify how child
programs are found a <em >ProcessType</em> value is used; to specify the maximum
time (in seconds) the child program is allowed to run a <em >size_t</em> values is
used.
<p>
By default, the stream buffers hold 200 bytes; all the child's standard
streams (standard input, output and error) are accessible from the <em >Parent</em>
process; the <em >PATH</em> environment variable is <em >not</em> used to locate the child
program; and the child processes will be allowed an unlimited amount of time
to run.
<p>
After constructing a <em >Process</em> object all default parameters may be
modified. These parameters may either be altered for a single process or a
<em >Process</em> object's general defaults may be modified. The <em >set*</em> members
(see below) may be used to change the default process parameters. When
parameters are specified otherwise, they will only be active for the next
process.
<p>
<h2 >CONSTRUCTORS</h2>
<p>
The command provided to the following constructors may be the
(initial part of the) specification of an external program to run. When the
program is eventually started it may start and end with a <em >back-tick</em>
(<em >`</em>). The back-ticks will be removed just before the specified program is
executed.
<p>
Child processes are <em >not</em> started automatically following <em >Process</em>
object constructions. A <em >start</em> member or the assignment operator (see
below) is used to start the specified child process.
<p>
The <em >mode</em> parameter that is defined for the second through fourth
constructor is defined as a <em >size_t</em> for backward compatibility reasons.
Internally, this argument is immediately converted to a <em >Process::IOMode</em>
value, silently ignoring values which do not represent valid <em >IOMode</em>
values. Multiple <em >IOMode</em> values may be combined using the bit-or operator.
<p>
After constructing a <em >Process</em> object its parameters can be changed
using <em >set</em>-member functions, function call operators or <em >start</em> members. 
<p>
<ul>
    <li> <strong >Process(std::string const &amp;cmd = "")</strong>:<br/>
       This constructor is used to specify the (initial part of a) command to
execute from a <em >Process</em> object. Default values are used for the
process parameters (see section <strong >PROCESS PARAMETERS</strong>).
<p>
<li> <strong >Process(size_t mode, std::string const &amp;cmd = "")</strong>:<br/>
        This constructor requires the specification of the object's 
<strong >IOMode</strong>, and it can be used to specify the (initial part of
a) command to execute from a <em >Process</em> object. Default values
are used for the remaining process parameters (see section <strong >PROCESS
PARAMETERS</strong>). 
<p>
<li> <strong >Process(size_t mode, ProcessType type, std::string const &amp;cmd = "")</strong>:<br/>
        This constructor requires the specification of the object's
<strong >IOMode</strong> and <em >ProcessType</em>, and it can be used to specify the (initial
part of a) command to execute from a <em >Process</em> object.  Default values are
used for the remaining process parameters (see section <strong >PROCESS
PARAMETERS</strong>).
<p>
<li> <strong >Process(size_t mode, ProcessType type, size_t timeLimit, 
std::string const &amp;cmd = "")</strong>:<br/>
        This constructor requires the specification of the object's
<strong >IOMode</strong>, <em >ProcessType</em>, and child process time limit. The (initial part
of a) command to execute from a <em >Process</em> object may optionally be
specified. The default process parameter is used for the sizes of the
internally used stream buffers (see section <strong >PROCESS PARAMETERS</strong>).
<p>
<li> <strong >Process(IOMode mode, ProcessType type, size_t timeLimit, size_t
        bufferSize, std::string const &amp;cmd = "")</strong>:<br/>
        This constructor requires the specification of the object's
<strong >IOMode</strong>, <em >ProcessType</em>, child process time limit, and size of the
internally used stream buffers. The (initial part of a) command to execute
from a <em >Process</em> object may optionally be specified. Note that this
constructor's <em >mode</em> parameter does not accept a <em >size_t</em> argument.
    </ul>
    The class <strong >Process</strong> does not offer copy or move constructors.
<p>
<h2 >OVERLOADED OPERATORS</h2>
<p>
<ul>
    <li> <strong >Process &amp;operator&lt;&lt;(Type value)</strong>:<br/>
        This operator inserts <em >value</em> into the child's standard
input stream. I.e., the child process reads <em >value</em> from its standard
input. A value of any type that can be inserted into an <em >ostream</em> can be
inserted into a <em >Process</em> object. Nothing happens if the member is used when
the child process has terminated. The behavior of this operator is undefined
unless <em >IOMode CIN</em> was specified.
<p>
<li> <strong >Process &amp;operator&gt;&gt;(Type value)</strong>:<br/>
        This operator extracts <em >value</em> from the child's standard output
stream and optionally (if <em >IOMode MERGE_COUT_CERR</em> was specified) from the
child's error stream. I.e., <em >value</em> may be extracted from <em >Process</em>
objects. A value of any type that can be extracted from an <em >istream</em>
can be extracted from a <em >Process</em> object. Nothing happens if the member is
used when the child process has terminated. The behavior of this operator is
undefined unless <em >IOMode COUT</em> or <em >MERGE_COUT_CERR</em> was specified.
<p>
<li> <strong >Process &amp;operator+=(std::string const &amp;)</strong>:<br/>
       This operator adds the provided <em >std::string</em> object to the currenly
defined command specification of a <em >Process</em> object. The member
<em >operator+=</em> does not add a separating blank space between the currently
stored command specification and the text to append.  It merely adds its
right-hand side string to the command stored so far. It does not affect a
currently running child process.
<p>
<li> <strong >int operator=(std::string const &amp;cmd)</strong>:<br/>
       The <em >operator=</em> member defines <em >cmd</em> as the  stored command in
a <em >Process</em> object.  
<p>
Before starting the child process a possibly active child process is first
stopped by calling <em >stop</em>. It returns <em >stop</em>'s return value.
<p>
<li> <strong >Process &amp;operator()(IOMode mode)</strong>:<br/>
        This operator changes the the <em >Process</em> object's <em >IOMode</em>
parameter. A reference to the <em >Process</em> object is returned, allowing
constructions like
        <pre>

    process(Process::COUT) = "/bin/cat"; 
        
</pre>

    to start a new child process with the specified <em >IOMode</em>. 
<p>
<li> <strong >Process &amp;operator()(IOMode mode, ProcessType type)</strong>:<br/>
        This operator changes the <em >Process</em> object's <em >IOMode</em> and
<em >ProcessType</em> process parameters.
<p>
<li> <strong >Process &amp;operator()(size_t mode, ProcessType type, size_t timeLimit)</strong>:<br/>
        This operator changes the <em >Process</em> object's mentioned process
parameters, silently converting the <em >size_t mode</em> to an <em >IOMode</em>
value. The currently specified default size of the stream buffers is kept
as-is.
<p>
<li> <strong >Process &amp;operator()(IOMode mode, ProcessType type, size_t timeLimit,
        size_t bufferSize)</strong>:<br/>
        This operator changes all of the <em >Process</em> object's process
parameters.
<p>
<li> <strong >Process &amp;operator|(Process &amp;lhs, Process &amp;rhs)</strong>:<br/>
        This operator implements process <em >piping</em>: information sent b
<em >lhs</em> to its standard output becomes the <em >rhs</em>'s standard input. The
operator returns <em >rhs</em>. 
<p>
This operator mimics the piping-operator supported by most command-shell
programs and should not be confused with the binary-or operator. The operator
starts the <em >lhs</em>'s  child process, but the <em >rhs</em>'s child
process (and thus pipe processing) must explicitly be started.
<p>
Since <em >operator|</em> is left-associative and <em >rhs</em> is returned piping can
be <em >chained</em>, allowing constructions like <em >p1 | p2 | p3</em>, where <em >p1, p2</em>
and <em >p3</em> are <em >Process</em> objects. 
<p>
The following idiom can be used to start the execution of a chain of
processes: <em >(p1 | p2 | p3).start()</em>. Alternatively, the following two-step
procedure can be used:
        <pre>

    p1 | p2 | p3;
    p3.start();
        
</pre>

<p>
If <em >p1</em> specifies <em >Process::CIN</em> then this <em >IOMode</em> is forwared to
the final process of the chain of processes. It is not necessary to specify
<em >Process::CIN</em> for <em >p3</em>. In fact, most <em >IOMode</em> flags of processes
passed to <em >operator|</em> are ignored or modified. Acceptable <em >IOModes</em> are
<em >Process::IGNORE_CERR</em> and <em >Process::CERR</em> (accepted for all processes),
<em >Process::CIN</em> (accepted for the first process of the chain), and
<em >Process::COUT</em> (for the last process of the chain). After connecting a
series of processes using <em >operator|</em> all input and output (except for the
standard error streams) is handled through the last process: if
<em >Process::CIN</em> is specified for the first process then this mode is
transferred to the last process, so information inserted into the last process
enters the pipe through the first process's standard input.
<p>
The next example illustrates how input can be inserted into the first
process from a main process and sent to the standard output stream by the
final process:
        <pre>
   
    using namespace std;
    using namespace FBB;

    Process p1(Process::CIN, "/bin/cat"); 
    Process p2("/bin/cat");
    Process p3(Process::STD, "/bin/cat");

    p1 | p2 | p3;

    p3.start();

    p3 &lt;&lt; cin.rdbuf() &lt;&lt; eoi;
        
</pre>
    
    Note that when specifying multiple commands using the piping operator
(<em >'|'</em>), traditionally <em >USE_SHELL</em> had to be specified, as the traditional
piping operator is a shell-feature. <em >Process's operator|</em> handles I/O piping
itself, and thus avoids the additional shell process.
    </ul>
    The default overloaded copy and move assignment operators are not
available.
<p>
<h2 >MEMBERS</h2>
<p>
<ul>
    <li> <strong >bool active()</strong>:<br/>
        This member returns <em >true</em> if the child process is currently running
and <em >false</em> if not.
<p>
<li> <strong >size_t available()</strong>:<br/>
        This member returns immediately. Its return value indicates whether
any information can be obtained from the child process as value(s) from the
<em >enum ChildOutput</em>. <em >NOTHING_AVAILABLE</em> is returned if no information is
ready for extraction. <em >CHILD_COUT</em> is returned if information from the child
process's standard output stream is available; <em >CHILD_CERR</em> is returned if
information from the child process's standard error stream is available;
<em >CHILD_COUT | CHILD_CERR</em> is returned if information from both the standard
output and standard error streams is available. The <em >bit_and</em> operator,
returning a <em >bool</em> value, can be used to determine which stream has any
pending information. E.g.,
        <pre>

    if (process.available() &amp; Process::CHILD_COUT)
        cout &lt;&lt; "Process has child standard output available";
        
</pre>

<p>
<li> <strong >size_t bufSize() const</strong>:<br/>
        This member returns the default size of the stream buffers that are
used for communication with child processes. If called while a child process
is actually running, then the value returned by this member may differ from
the value that was actually used when starting the child process, as the
default value may be altered by a function call operator just before starting
the child process.
<p>
<li> <strong >std::istream &amp;cerr()</strong>:<br/>
        This member should be avoided. Use <em >childErrStream</em> instead.<br/>
<p>
<li> <strong >std::istream &amp;childErrStream()</strong>:<br/>
        If <em >Process::CERR</em> was specified then this member interfaces
to the child's standard error stream. By extracting the information from
<em >childErrStream</em> the parent process retrieves the information sent by its
child process to its standard error stream.
<p>
<li> <strong >std::istream &amp;childOutStream()</strong>:<br/>
        If <em >Process::COUT</em> or
<em >Process::MERGE_COUT_CERR</em> was specified then this member interfaces
to the child's standard output stream. By extracting the information from
<em >childOutStream</em> the parent process retrieves the information sent by its
child process to its standard output stream. Alternatively, this information
may directly be extracted from the <em >Process</em> object itself, but this member
does not require the use of a <em >static_cast</em> to disambiguate the intended
stream buffer in statements like
        <pre>

    cout &lt;&lt; process.childOutStream().rdbbuf()
        
</pre>

<p>
<li> <strong >void close()</strong>:<br/>
        This member closes the child's input stream. In situations where the
child continuously reads information from its standard input stream this
member can be used to inform the child process that input has terminated. This
member should only be used when <em >IOMode CIN</em> was specified for the currently
running child process; otherwise its behavior is undefined. Alternatively, the
<em >eoi</em> member or manipulator may be used.
<p>
<li> <strong >int eoi()</strong>:<br/>
        This member closes the child's input stream, and then calls
<em >waitForChild</em> to wait for the child process to end. In situations where the
child continuously reads information from its standard input stream this
member can be used to inform the child process that input has terminated. This
member should only be used when <em >IOMode CIN</em> was specified for the currently
running child process; otherwise its behavior is undefined. Alternatively, the
<em >close</em> member or <em >eoi</em> manipulator may be used. The exit-status of the
called child process is returned.
<p>
<li> <strong >std::istream &amp;errStream()</strong>:<br/>
        This member may be used to extract information written by the child
process to its standard error stream.  This member should only be used when
<em >IOMode CERR</em> was specified for the currently running child process;
otherwise its behavior is undefined.<br/>
<p>
<li> <strong >int exitStatus() const</strong>:<br/>
        After calling <em >eoi</em> or inserting the <em >eoi</em> manipulator into the
<em >Process</em> object this member returns the child process's exit status.
<p>
<li> <strong >IOMode ioMode() const</strong>:<br/>
        This member returns the default <em >IOMode</em>. If called while a child
process is actually running, then the value returned by this member may differ
from the value that was actually used when starting the child process, as the
default value may be altered by a function call operator just before starting
the child process.
<p>
<li> <strong >ProcessType processType() const</strong>:<br/>
        This member returns the default <em >ProcessType</em> of child proceses. If
called while a child process is actually running, then the value returned by
this member may differ from the value that was actually used when starting the
child process, as the default value may be altered by a function call operator
just before starting the child process.
<p>
<li> <strong >size_t timeLimit() const</strong>:<br/>
        This member returns the default time limit (in seconds) of child
processes. A return value of zero indicates that no time limit is enforced. If
called while a child process is actually running, then the value returned by
this member may differ from the value that was actually used when starting the
child process, as the default value may be altered by a function call operator
just before starting the child process.
<p>
<li> <strong >void setBufSize(size_t bufSize)</strong>:<br/>
        This member changes the default stream buffer size that is used for
communication with child processes. A zero byte buffer size is silently
changed into one. The new default value will be used when starting the next
child process.
<p>
<li> <strong >void setCommand(std::string const &amp;cmd)</strong>:<br/>
       The <em >setCommand</em> member (re)defines the (initial part of a) child
process command specification.
<p>
This member does not actually start the child process, and <em >operator+=</em>
may be used to append additional text to the command specification. Also, this
member may be used when a child process is currently active: its use does not
affect a currently running child process.
<p>
<li> <strong >void setIOMode(iomode mode)</strong>:<br/>
        This member changes the default <em >IOMode</em>. The new default value will
be used when starting the next child process.
<p>
<li> <strong >void setProcessType(ProcessType type)</strong>:<br/>
        This member changes the default <em >ProcessType</em>. The new default value
will be used when starting the next child process.
<p>
<li> <strong >void setTimeLimit(size_t timeLimit)</strong>:<br/>
        This member changes the default execution time limit (in seconds). No
time limit will be imposed upon child processes if <em >timeLimit 0</em> is
specified. The new default value will be used when starting the next child
process.
<p>
<li> <strong >void start()</strong>:<br/>
        The currently specified command is started using the <em >Process</em>
object's process parameters. 
<p>
Having specified a command to start, the first white-space delimited
element of the specified command is used as the name of the program to
start. If the program should be called through <strong >sh</strong>(1), the <em >USE_SHELL
ProcessType</em> or a <em >system</em> member should be used.
<p>
If a child process does not terminate by itself, then it is terminated
when it has run for its alloted time; when the <em >Process</em> object's <em >start</em>
or <em >stop</em> members are called; when the object's assignment operator is used;
or when the object goes out of scope.
<p>
Alternatively, the member <em >waitForChild</em> (see below) may have to be
called to end a running process.
<p>
<li> <strong >void start(IOMode mode)</strong>:<br/>
       The currently specified command is started using the specified
<em >IOMode</em>, but otherwise using the currently configured <em >Process</em> object's
process parameters. The specified <em >IOMode</em> is only used for the child
process that is started by this member.
<p>
<li> <strong >void start(IOMode mode, ProcessType type)</strong>:<br/>
       The currently specified command is started using the specified
<em >IOMode</em> and <em >ProcessType</em>, but otherwise using the currently configured
<em >Process</em> object's process parameters. The specified process parameter
values are only used for the child process that is started by this member.
<p>
<li> <strong >void start(size_t mode, Program program, size_t timeLimit)</strong>:<br/>
       The currently specified command is started using the specified
<em >IOMode</em>, <em >ProcessType</em>, and time limit (silently converting the <em >size_t
mode</em> to an <em >IOMode</em> value), and using the currently configured <em >Process</em>
object's stream buffer size parameter. The specified process parameter values
are only used for the child process that is started by this member.
<p>
<li> <strong >void start(IOMode mode, Program program, size_t timeLimit, size_t
        bufferSize)</strong>:<br/> 
       The currently specified command is started using the specified process
parameters. The specified parameter values are only used for the child process
that is started by this member.
<p>
<li> <strong >void showMode(char const *lab) const</strong>:<br/>
        This member displays the label <em >lab</em>, followed by the current
process ID, followed by the child process's process ID, followed by a textual
representation of the currently active <em >IOMode</em>.
<p>
<li> <strong >std::string const &amp;str() const</strong>:<br/>
        This member returns the contents of the current child process command
specification. It shows the command as it will be (or has been) executed by
<em >start</em>, <em >system</em> or the assignment operator. 
<p>
<li> <strong >void system()</strong>:<br/>
        This member executes the currently stored command as a command to
<strong >sh</strong>(1).  When using <em >system</em> redirections can be included in the command
itself (this renders the redirected streams implied by the current <strong >IOMode</strong>)
useless. The currently set process parameters are used when <strong >sh</strong>(1) is
executed.
<p>
<li> <strong >void system(IOMode mode)</strong>:<br/>
        This member executes the currently stored command as a command to
<strong >sh</strong>(1) (cf. <em >system</em> above) using the specified <em >IOMode</em> rather than
the current default <em >IOMode</em> setting.
<p>
<li> <strong >void system(IOMode mode, size_t timeLimit)</strong>:<br/>
        This member executes the currently stored command as a command to
<strong >sh</strong>(1) (cf. <em >system</em> above) using the specified <em >IOMode</em> and time
limit.
<p>
<li> <strong >void system(IOMode mode, size_t timeLimit, size_t bufSize)</strong>:<br/>
        This member executes the currently stored command as a command to
<strong >sh</strong>(1) (cf. <em >system</em> above) using the specified <em >IOMode</em>, time
limit, and stream buffer size values.
<p>
<li> <strong >int stop()</strong>:<br/>
       This member terminates a currently active child process. The child
process is twice sent a <em >SIG_TERM</em> signal, followed by a <em >SIG_KILL</em>
signal. This member returns the exit-value of the child process that was
stopped. Its operation and return value are undefined if called without a
running child process.
<p>
Following <em >stop</em> a new command may be called using <em >start, system</em> or
the assignment operator (see earlier). Those members first calls <em >stop</em>.
When the intention is to start another child process, then there's no need to
call <em >stop</em> explicitly. Also, <em >stop</em> is called when the <em >Process</em> object
goes out of scope.
<p>
<li> <strong >int waitForChild()</strong>:<br/>
        This member is inherited from the class <em >FBB::Fork</em>. It waits for a
child process to end. It is called to prevent premature termination of a
child process before calling <em >stop</em>. It is not always necessary to call
<em >waitForChild</em>. E.g., when a process writes to its standard output stream
and all output has been read then the child process can be stopped without
calling <em >waitForChild</em>.
    </ul>
<p>
<h2 >MANIPULATOR</h2>
    <ul>
    <li> <strong >FBB::eoi</strong>:<br/>
        This manipulator may be inserted into a <em >Process</em> object for which
<em >IOMode CIN</em> was specified. It closes the child's input stream, and then
calls <em >waitForChild</em> to wait for the child process to end. In situations
where the child continuously reads information from its standard input stream
this member can be used to inform the child process that input has
terminated. Alternatively, <em >Process</em> object's <em >close</em> or <em >eoi</em> members
may be used.
    </ul>
<p>
<h2 >EXAMPLES</h2>
<p>
The first example shows how a program only producing output can be
called. Its child process simply is <em >/bin/ls</em>:
        <pre>
int main()
{
    Process process(Process::COUT, "/bin/ls -Fla");

    process.start();
    cout &lt;&lt; process.childOutStream().rdbuf();
}

</pre>

<p>
The next example shows how a child program can be given a limited amount
of execution time: lines entered at the keyboard are echoed to the standard
output stream for at most 5 seconds:
        
<p>
The final example shows how multi threading can be used to access the
child program's standard output and standard error streams through the
<em >Process</em> object:
        <pre>
void collect(ostream *outStream, streambuf *rdbuf)
{
    *outStream &lt;&lt; rdbuf &lt;&lt; flush;
}

int main()
{
    string cmd(getcwd(0, 0));
    cmd += "/cincoutcerr";

    Process all(Process::ALL, cmd);

    all.start();

    thread outThread(collect, &amp;cout, all.childOutStream().rdbuf());
    thread errThread(collect, &amp;cerr, all.childErrStream().rdbuf());

    all &lt;&lt; cin.rdbuf() &lt;&lt; eoi;

    outThread.join();
    errThread.join();
}

</pre>

<p>
Additional examples are found in the distribution's
<em >bobcat/process/driver</em> directory. 
<p>
<h2 >FILES</h2>
    <em >bobcat/process</em> - defines the class interface
<p>
<h2 >SEE ALSO</h2>
    <strong >bobcat</strong>(7), <strong >execle</strong>(3), <strong >fork</strong>(3bobcat), <strong >iostream</strong>(3fork),
    <strong >sh</strong>(1)
<p>
<h2 >BUGS</h2>
    With the release of Bobcat 1.21.1 the class <em >Process</em> was completely
rewritten. The new implementation, however, should not affect existing
programs other than that <em >Process</em> will no longer impose a limited
time-to-live upon child processes. The interface was enlarged, but this should
not affect existing programs. The internal organization of the <em >Process</em>
class <em >has</em> changed though, requiring recompilation of sources defining
<em >Process</em> class type objects and linking dynamically to the <em >Bobcat</em>
library. 
<p>
With the release of Bobcat 2.11.0 another major modification of
<em >Process</em> was realized. Although <em >Process</em>'s internal organization was
again modified this does not affect exeisting programs using <em >Process</em>
objects. No recompilation of existing sources using <em >Process</em> is required.
<p>

<h2 >DISTRIBUTION FILES</h2>
    <ul>
    <li> <em >bobcat_4.04.00-x.dsc</em>: detached signature;
    <li> <em >bobcat_4.04.00-x.tar.gz</em>: source archive;
    <li> <em >bobcat_4.04.00-x_i386.changes</em>: change log;
    <li> <em >libbobcat1_4.04.00-x_*.deb</em>: debian package holding the
            libraries;
    <li> <em >libbobcat1-dev_4.04.00-x_*.deb</em>: debian package holding the
            libraries, headers and manual pages;
    <li> <em >http://sourceforge.net/projects/bobcat</em>: public archive location;
    </ul>
<p>
<h2 >BOBCAT</h2>
    Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
<p>
<h2 >COPYRIGHT</h2>
    This is free software, distributed under the terms of the 
    GNU General Public License (GPL).
<p>
<h2 >AUTHOR</h2>
    Frank B. Brokken (<strong >f.b.brokken@rug.nl</strong>).
<p>