![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Redirect a file descriptor into a temporary file for a scope, and give back what was written to it. More...
Public Member Functions | |
| FdCapture (int fd) | |
| ~FdCapture () | |
| std::string | take () |
| Restore the descriptor and read back what was written. | |
| bool | active () const |
Redirect a file descriptor into a temporary file for a scope, and give back what was written to it.
A TEMPORARY FILE AND NOT A PIPE, which was already the choice here and is worth keeping deliberately: a pipe holds 64 KB and nobody is draining it, so a solve that prints more than that would deadlock against its own output.
IT IS AN OBJECT so that the restore happens on the way out of the scope whatever happens inside it. The server's version below did the same dance inline and could not have survived a throw between the dup2 and the restore, which is survivable in a one-shot process and is a leaked file descriptor per call in a host that calls this in a loop.
Definition at line 11801 of file line_cli.cpp.
|
inlineexplicit |
Definition at line 11803 of file line_cli.cpp.
|
inline |
Definition at line 11823 of file line_cli.cpp.
|
inline |
Definition at line 11843 of file line_cli.cpp.
Referenced by run_invocation_captured().
|
inline |
Restore the descriptor and read back what was written.
Idempotent.
Definition at line 11832 of file line_cli.cpp.
Referenced by line::cli::run(), and run_invocation_captured().