FBB::CinInserter(3bobcat)
π FBB::CinInserter π
okay bestie, gather round, we're talking about FBB::CinInserter β it lives in the Executing Child Processes section of the bobcat manual, and it is lowkey iconic for one specific job: it runs external programs for you and feeds them stuff on standard input. π«Ά
β¨ NAME β¨
FBB::CinInserter β runs external programs reading standard input. that's it, that's the whole job description, and she does it well π
πΈ SYNOPSIS πΈ
#include <bobcat/cininserter>
Linking option: -lbobcat
include the header, link the lib, you're literally set bestie β¨
π DESCRIPTION π
So here's the vibe: the FBB::CinInserter class gives you a basic interface for calling external programs (aka child processes) that read from their standard input streams, and she handles the feeding. πΌ
By default, the child process's standard output and standard error streams are not handled by CinInserter objects. Not her department. What she does provide is the child's standard input: anything you insert into a CinInserter object gets forwarded straight to the child process's standard input stream. so it's giving very much "here's your lunch, eat up" energy π
β οΈ heads up, and this one matters: the PATH environment variable is not used when calling child processes. child process programs must be specified using paths. no shortcuts, no vibes-based lookup, actual paths only.
CinInserter objects may repeatedly be used to execute the same or different child processes. but β and this is the rules-of-the-house moment β before starting the next child process, the current child process must have finished. one at a time, bestie, we are not chaotic here π
Now, arguments passed to child processes may be surrounded by double or single quotes:
- double quotes β the double quotes get removed, and any escape sequences used inside get interpreted. β¨
- single quotes β the single quotes get removed, and the content is accepted as-is. no interpretation, no editing, just vibes preserved exactly as written. π
- unquoted escape sequences β you can also just drop those in, and they get evaluated and replaced by their intended characters (for example,
\100is converted to@). π₯
And now the interesting problem, because there always is one: when information of undetermined size or structure must be inserted into a child process, the child process cannot determine when to stop. which is a whole situation. here's the breakdown: the child process starts, and the parent process must wait until its child process has finished processing its input. but input can only be forwarded to the child's input stream after the child process has started. circular much?? π
To solve this, InterterFork offers an overloaded execute member, which passes information to the child process via a separate thread. problem solved, slay. π
π NAMESPACE π
FBB
All constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. π
π INHERITS FROM π
FBB::Exec (private), FBB::OFdBuf (private), std::ostream.
she's got three parents and she's thriving, we love a multi-talented queen π
π§ CONSTRUCTOR π§
CinInserter(size_t bufSize = 100)β you can pass abufSizeargument, and it defines the internal buffer size used by theCinInserter's streambuf. and by default the standard output and standard error streams are not handled. π«§CinInserter(Mode mode, size_t bufSize = 100)β themodeargument must beCinInserter::CLOSE_STD. that value means the standard output and standard error streams get redirected to/dev/null, so any standard output generated by child processes is straight up ignored. ποΈ and yeah, you can pass abufSizehere too β it defines the internal buffer size used by theCinInserter's streambuf.
β¨ also important: copy and move constructors (and assignment operators) are not available. no duplicating her, no relocating her. she's one of one, periodt. π
π¦ DESTRUCTOR π¦
The destructor ends the CinInserter's child process, if it is still active. she cleans up after herself, always. πΈ
β MEMBERS β
void execute(std::string const &cmd)β the argument specifies the command to execute, and the command itself must be specified as a path (thePATHenvironment variable isn't used, remember). This member immediately returns, after which you can insert information into theCinInserterobject, and that information gets forwarded to the child process's standard input stream. see also the description of the next (overloaded)executemember function. π
Once all information has been inserted, the child process's standard input stream must be closed. this is realized by either calling stop; by calling execute once again; or by ending the CinInserter object's lifetime. pick your poison bestie, all three work. π
Arguments specified in the cmd string are passed to the child process, and may optionally be specified using single or double quotes, as described in this man-page's DESCRIPTION section. π
bool execute(std::string const &cmd, std::string const &text)β this member is the one you use to forward a limited amount of information (the stuff living in thetextparameter) to the child process specified atcmd(defined identically as thecmdparameter of the previousexecutemember, no cap).
This member returns true if the child process's exit value equals 0. β
int stop()β call this function after all information has been inserted into theCinInserterobject to close the child process's standard input stream. It is not required after callingexecute(cmd, text), or when callingexecuteagain, or when theCinInserterobject's lifetime ends.
This member returns the exit code of the last executed child process, which may also be obtained from the next member: π
int ret() constβ once a child process has finished, this member provides the actual exit code of the child process. Its value equals-1before the firstexecutecall. so if you're seeing-1, nothing has run yet, don't panic. π«Ά
π PROTECTED MEMBER π
Pipe &childInPipe()β if derived classes need to override the redirections-members then they probably need access to the pipe read by the child process. This member provides a reference to that pipe. By default the parent process inserts information into the pipe, while the child process reads the inserted information from the pipe. a little relay race, but make it unix. πβοΈ
π EXAMPLE π
like, here's the whole thing in action, copy-paste worthy fr fr:
#include <iostream>
#include <fstream>
#include <bobcat/cininserter>
using namespace std;
using namespace FBB;
int main()
{
CinInserter inserter;
inserter.execute("/bin/cat");
ifstream in("build");
inserter << in.rdbuf();
cout << "child returns: " << inserter.stop() << β\nβ;
inserter.execute("/bin/cat");
in.seekg(0); // reset to the beginning
inserter << in.rdbuf();
// when immediately followed by another execute, βstopβ is optional
inserter.execute("/bin/cat", "a simple text\n");
inserter.execute("/bin/cat", "a simple text\n");
bool bret = inserter.execute("/bin/cat", "a simple text\n");
cout << "direct string insertion: " << bret << β\nβ;
}
π FILES π
bobcat/cininserterβ provides the class interface.
π SEE ALSO π
bobcat(7), cerrextractor(3bobcat), coutextractor(3bobcat), execl(3), exec(3bobcat), fork(3bobcat), pipe(3bobcat), process(3bobcat), stdextractor(3bobcat).
the whole friend group, go say hi π
π BUGS π
None reported. and honestly? we love a clean record. π
π 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'. cute name, iconic origin story. β¨
π COPYRIGHT π
This is free software, distributed under the terms of the GNU General Public License (GPL). free as in freedom bestie, we stan π
π AUTHOR π
Frank B. Brokken (f.b.brokken@rug.nl). thank you for your service king π«‘
and that's the whole page!! this one comes to you from libbobcat-dev_6.15.01, dated 2005-2026, and it's the manual page for FBB::CinInserter(3bobcat). go forth and pipe things into child processes responsibly, bestie πβ¨π
π¦ 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