//----------------------------------------------------------------------------
//
// TSDuck - The MPEG Transport Stream Toolkit
// Copyright (c) 2005-2025, Thierry Lelegard
// BSD-2-Clause license, see LICENSE.txt file or https://tsduck.io/license
//
//----------------------------------------------------------------------------

<<<
=== fork (input)

[.cmd-header]
Receive packets from a forked process

This input plugin forks a process and receives all TS packets from the standard output of this process.

Using this input plugin with `tsp` is equivalent to reading the input pipe.
The following two commands have the same effect (the command `receive` being a fictitious one):

[source,shell]
----
$ receive stream | tsp -P ...
$ tsp -I fork 'receive stream' -P ...
----

So, this plugin is redundant with the shell pipe features.
However, this plugin is useful when the `tsp` process is created from another native application (not a shell script).
In that case, it is much easier for this application to create a simple binary process rather than a shell and its commands.

Additionally, this input plugin becomes necessary with `tsswitch` which accepts several inputs.
The following command has no equivalent with shell pipes:

[source,shell]
----
$ tsswitch -I fork 'receive stream1' -I fork 'receive stream2' -O ...
----

[.usage]
Usage

[source,shell]
----
$ tsp -I fork [options] 'command'
----

[.usage]
Parameter

[.opt]
_'command'_

[.optdoc]
The _'command'_ parameter specifies the shell command to execute in the forked process.
The standard output of this process is a pipe from which the TS packets are received by the input plugin.
If the command contains spaces or shell special sequences, the complete command string must be surrounded by quotes.


[.optdoc]
If the command is too long or too complicated, it is recommended to use a script.
If the created command is another TSDuck command, it is possible to shorten the command using partial command line redirection
(see xref:cmd-redirection[xrefstyle=short]).

[.usage]
Options

include::{docdir}/opt/opt-format.adoc[tags=!*;input]

[.opt]
*-n* +
*--nowait*

[.optdoc]
Do not wait for child process termination at end of input.

[.usage]
Windows specific options

[.opt]
*-b* _value_ +
*--buffered-packets* _value_

[.optdoc]
Specifies the pipe buffer size in number of TS packets.

include::{docdir}/opt/group-common-inputs.adoc[tags=!*]
