Ferreteria/v0.6/clade/IO/Aspect/Connx/Process/@fx/Run

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | IO‎ | Aspect‎ | Connx‎ | Process
Jump to navigation Jump to search
fx: Run()

About

  • Action: Sends the command, buffers the response, closes the command process

This and PipeToStream() (which it calls) have a lot of overlap with what Convey() does, and I'm trying to figure out if they can be consolidated.

  • Q1: what is the relationship between a Buffer and a Stream?
    • A: Tentatively, a Buffer is actually a type of Stream -- so we should be able to pass a Buffer wherever a Stream is needed.
  • Q2: What is the relationship between GetErrsBuff() and $oaPipes->ErrsQRes()?
    • A:

History

  • 2024-11-24 created. This is experimental; if it works, this kind of thing should probably be encapsulated in its own class.
  • 2024-11-25 moved from shell/Secure to Shell

Code

As of 2025-12-23:

#
    public function Run() : CommOpIface {
        $this->Open();

        $oBuffErrs = $this->GetErrsBuff();
        $oBuffRecv = $this->QORecvBuff()->GetIt();

        $oBuffErrs->Open();
        $oBuffRecv->Open();

        $oaPipes = $this->OAPipes();

        $this->PipeToStream($oaPipes->SrceRsrc(),$oBuffRecv,TRUE);     // receive any output from process
        $this->PipeToStream($oaPipes->ErrsRsrc(),$oBuffErrs,FALSE);    // check for error messages from process

        $oAct = $this->GetOpStator();
        if ($oBuffErrs->HasBytes()) {
            $sMsg = $oBuffErrs->PullBytes();

            $oAct->SetOkay(FALSE);
            $oAct->AddMsgObject(new MsgClass($sMsg));
            $oAct->QResponseErr()->SetIt($sMsg);
        } else {
            $oAct->SetOkay(TRUE);
            if (!$oBuffRecv->HasBytes()) {
                $oAct->AddMsgString('No error messages, but also no regular output received.');
            }
        }

        $this->Shut();
        $oBuffRecv->Shut();
        $oBuffErrs->Shut();

        return $oAct;
    }