FBB::Co...tractor(3bobcat)
π¦ NAME π¦
FBB::CoutExtractor β runs external programs and catches the standard output they write π
β¨ SYNOPSIS β¨
#include <bobcat/coutextractor>
Linking option: -lbobcat
π DESCRIPTION π
okay so, bestie, listen π The FBB::CoutExtractor class gives you a basic interface for calling external programs (the so-called child processes) that write to their standard output streams. By default, an object of this type does not handle the child process's standard input or standard error streams β nope, not those, not by default π. What it does do is read the child's standard output through the CoutExtractor object: anything the child process writes to its standard output gets extracted (i.e. read) from the CoutExtractor object π.
ngl, there's a catch: the PATH environment variable is not used when calling child processes. So child process programs have to be specified using paths. That's the vibe, fr fr π
You can reuse CoutExtractor objects over and over to execute the same child process or a completely different one. Recycling is main character energy β»οΈβ¨
Arguments passed to child processes may be surrounded by double or single quotes:
- double-quoted arguments β the double quotes get removed, and any escape-sequences inside are interpreted πͺ
- single-quoted arguments β the single quotes get removed, and the content is accepted exactly as-is π
- unquoted escape-sequences can also be specified β those get evaluated and replaced by their intended characters (like
\100becomes@) π₯
π NAMESPACE π
FBB
Every constructor, member, operator and manipulator mentioned in this man-page lives in the namespace FBB π
πΈ INHERITS FROM πΈ
FBB::Exec (private), FBB::IFdBuf (private), std::istream
π CONSTRUCTOR π
CoutExtractor(size_t bufSize = 100)β you may pass abufSizeargument; it defines the internal buffer size used by theCoutExtractor's streambuf. By default the standard input and standard error streams are not handled.CoutExtractor(Mode mode, size_t bufSize = 100)β themodeargument must beCoutExtractor::CLOSE_STD. It says that the standard input and standard error streams get redirected to/dev/null: the child processes then can't read their standard input streams, and any standard error output the child processes generate is ignored π. AbufSizeargument may also be specified: it defines the internal buffer size used by theCinInserter's streambuf.
Copy and move constructors (and assignment operators) are not available. Not even a little bit. Periodt π«
β¨ MEMBERS β¨
void execute(std::string const &cmd)β the argument specifies the command to execute: the command itself must be specified as a path (thePATHenvironment variable isn't used π«Ά). This member returns immediately, and after that, any information the child process writes to its standard output stream may be extracted from theCoutExtractorobject.
Once execute has returned you can call it again, either with the same command or another one π
Arguments passed to the program being executed as a child process may optionally be specified using single or double quotes, as described in this man-page's DESCRIPTION section π
int ret() constβ onceexecutehas returned, this member gives you the actual exit code of the child process. Before the firstexecutecall, its value equals-1β
π PROTECTED MEMBER π
Pipe &childOutPipe()β if derived classes need to override the redirection-members, then they probably need access to the pipe the child process writes to. This member provides a reference to that pipe. By default the parent process reads information from the pipe, while the child process inserts its standard output into the pipe π¦
π₯ EXAMPLE π₯
#include <iostream>
#include <bobcat/coutextractor>
using namespace std;
using namespace FBB;
int main()
{
CoutExtractor extractor;
extractor.execute("/bin/cat driver.cc");
cout << extractor.rdbuf();
cerr << "Returning: " << extractor.ret() << "\n"
"again:\n";
extractor.execute("/bin/cat driver.cc");
cout << extractor.rdbuf();
cerr << "Returning: " << extractor.ret() << β\nβ;
}
π FILES π
bobcat/coutextractor β provides the class interface π
π SEE ALSO π
bobcat(7), cerrextractor(3bobcat), cininserter(3bobcat), execl(3), exec(3bobcat), fork(3bobcat), process(3bobcat), stdextractor(3bobcat).
π BUGS π
None reported. We ate and left no crumbs πβ¨
π§ BOBCAT PROJECT FILES π§
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
libbobcat6: debian package containing the shared library, changelog and copyright note;libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;
π BOBCAT π
Bobcat is an acronym of Brokkenβs Own Base Classes And Templates. Iconic, honestly π
π COPYRIGHT π
This is free software, distributed under the terms of the GNU General Public License (GPL). Free software slay π«Ά
π AUTHOR π
Frank B. Brokken (f.b.brokken@rug.nl). Legend behaviour, no cap π
k that's the whole thing, bestie π This was FBB::Co...tractor(3bobcat), the "Executing Child Processes" page, from libbobcat-dev_6.15.01, dated 2005-2026. Go read /bin/cat some files and stream their output, you got this π¦β¨
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms