--- a/src/AwkHandler.h Sun May 05 11:54:53 2019 +0200
+++ b/src/AwkHandler.h Sun May 05 12:37:43 2019 +0200
@@ -50,6 +50,14 @@
using namespace relpipe::reader;
using namespace relpipe::reader::handlers;
+/**
+ * This transformation consists of three processes connected together using pipes.
+ *
+ * Processes:
+ * - Parent: process RelationalReaderStringHandler events (read relational data, usually from STDIN) and pass them in the special text format to the pipe1
+ * - AWK: external program (/usr/bin/awk), read from the pipe1, writes to the pipe2
+ * - Writer: reads from the pipe2 and writes to relationalWriter (relational data, usually to STDOUT)
+ */
class AwkHandler : public RelationalReaderStringHandler {
private:
Configuration configuration;
@@ -78,6 +86,7 @@
void cleanUp() {
if (awkInputWriterFD >= 0) {
closeOrThrow(awkInputWriterFD);
+ // TODO: check exit codes
__pid_t waitResult1 = wait(NULL);
__pid_t waitResult2 = wait(NULL);
awkInputWriterFD = -1;
@@ -112,9 +121,8 @@
redirectFD(awkInputReaderFD, STDIN_FILENO);
redirectFD(awkOutputWriterFD, STDOUT_FILENO);
-
+ // Runs AWK program found on $PATH → user can plug-in a custom implementation or a wrapper, but this can be also bit dangerous (however AWK itself is dangerous).
execlp("awk", "awk", "{print \"AWK says: line \" NR \" = \" $0;}", nullptr);
-
} else {
// Parent process
closeOrThrow(awkInputReaderFD);