[Gambas-user] Blocking read from a Process you had to write to

Cedron Dawg cedron at exede.net
Tue Mar 19 13:26:04 CET 2019


You might remember a while back I was trying to have a Gambas Program "make" a shared library for development purposes.

This is what I have in the Gambas program:

   Dim theResult As String
   Exec ["sh", "<full path specified>/m"] 'To theResult
   Print "I'm back: ***"; theResult; "***"

The "m" file looks like this:

----------------------------
cd <full path specified>/
make
----------------------------

The "make" file looks like this:

----------------------------
libGambas_NiceTerminal.so: libGambas_NiceTerminal.o 
<tab>gcc -shared -o libGambas_NiceTerminal.so libGambas_NiceTerminal.o

libGambas_NiceTerminal.o: libGambas_NiceTerminal.c 
<tab>gcc -c -Wall -Werror -fpic libGambas_NiceTerminal.c 
----------------------------

I got what I considered strange behavior.  What I want is for theResult to hold all the error messages, so I can test the return value and stop execution.

So, I introduced a deliberate error into the code (sacrilege).

Running with the "To theResult" in effect, console output looks like this:

----------------------------
I'm back: ***gcc -c -Wall -Werror -fpic ./libGambas_NiceTerminal.c 
***
----------------------------

Commenting it out results in:

---------------------------
I'm back: ******
gcc -c -Wall -Werror -fpic ./libGambas_NiceTerminal.c 
./libGambas_NiceTerminal.c: In function ‘NT_Open’:
./libGambas_NiceTerminal.c:20:1: error: ‘ggfgd’ undeclared (first use in this function)
 ggfgd
 ^
./libGambas_NiceTerminal.c:20:1: note: each undeclared identifier is reported only once for each function it appears in
./libGambas_NiceTerminal.c:23:9: error: expected ‘;’ before ‘return’
         return "Pretending to open!";
         ^
./libGambas_NiceTerminal.c:24:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1: all warnings being treated as errors
make: *** [libGambas_NiceTerminal.o] Error 1
---------------------------

I expected theResult to hold all that info since it is supposed to capture the standard output.  It doesn't seem to.  I didn't report it because I'm not sure my usage is correct and I didn't want to spend any more time on it.  Instead, for this project, I decided to go pure Gambas.  I haven't had a need to revisit this issue so it has been laying fallow, but this seems to be a good time to bring it up.

Ced



----- Original Message -----
From: "Benoît Minisini" <g4mba5 at gmail.com>


Lost. The Process object won't maintain a read buffer for you, unless 
you use the syntax EXEC ... TO ...

This is why you have to use the Read event and a global buffer.

But I think you can easily embed that management in a class.

Regards,

-- 
Benoît Minisini

----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----


More information about the User mailing list