1. Oddities in pipeio

For my program, I needed the pipeio.e library, after reading the documentation, I decided to try an example from there. Neither in Euphoria, nor in OE, nor in Phix, it did not work in windows XP. By the way in Phix this library does not work without improvement

include std/pipeio.e as pipe 
integer i 
  object z = pipe:create()  
  object p = pipe:exec("dir", z)  
  if atom(p) then  
    sprintf("Failed to exec() with error %x", pipe:error_no()) 
 
  else 
	  object c = pipe:read(p[pipe:STDOUT], 6024) 	    	 
  end if  
  pipe:kill(p) 
?1/0 
i=getc(0) 

It does not work exactly for the "dir" command"

new topic     » topic index » view message » categorize

2. Re: Oddities in pipeio

In Phix, pipeio. e doesn't want to work relentlessly:

global integer address_length 
-- address length for pointers 
-- * 4 on 32-bit OSes 
-- * 8 on 64-bit OSes 
--</desc> 
--</variable> 
address_length = 4 
global procedure poke_pointer(atom addr, object x) 
--<procedure> 
--<name>poke_pointer</name> 
--<digest>put a 4 byte pointer in memory</digest> 
--<desc> 
--</desc> 
--<param> 
--<type>atom</type> 
--<name>addr</name> 
--<desc></desc> 
--</param> 
--<param> 
--<type>object</type> 
--<name>x</name> 
--<desc></desc> 
--</param> 
--<return> 
--</return> 
--<example> 
-- poke_pointer(addr, allocate_string("where?")) 
--</example> 
--<see_also>peek_pointer()</see_also> 
--</procedure> 
  if addr <= 0 then 
    printf(1,"poke_pointer: bad pointer %d\n", addr) 
  end if 
  poke4(addr, x) 
end procedure 
 
-------------------------------------------------------------------------------- 
 
global function peek_pointer(object addr) 
--<function> 
--<name>peek_pointer</name> 
--<digest>read a 4 byte pointer in memory</digest> 
--<desc> 
--</desc> 
--<param> 
--<type>object</type> 
--<name>addr</name> 
--<desc></desc> 
--</param> 
--<return> 
--</return> 
--<example> 
-- addr2 = allocate_string("where?") 
-- ? addr2 
-- poke_pointer(addr, addr2) 
-- ? peek_pointer(addr) --> same as addr2 
--</example> 
--<see_also>poke_pointer()</see_also> 
--</function> 
  if atom(addr) and (addr <= 0) then 
    printf(1,"peek_pointer: bad pointer %d\n", addr) 
  end if 
  if sequence(addr) and (addr[1] <= 0) then 
    printf(1,"peek_pointer: bad pointer %d\n", addr[1]) 
  end if 
  return peek4u(addr) 
end function 
 
global function size_of( atom ctype ) 
  if ctype = #03000001 then 
    return address_length 
  elsif ctype = #03000002 then  -- T_LONGLONG 
    return 8 
  else 
    return and_bits( ctype, #FF ) 
  end if 
end function 

And for some reason, after the shutdown, a Phix error comes out, which I do not understand

f:\phix\pmsgs.e:337 in procedure Warnings() 
attempt to divide by 0 
    fn = 1 
    wi = {``,0,{`procedure error is not used.`,`F:\phix\out\pipeio.e`,311}} 
    buttons = {`Next`,`&Skip remainder`,0} 
    witxt = "Warning: F:\\phix\\out\\pipeio.e:311 procedure error is not used.\n" 
    fn1 = 1 
    r = <novalue> 
    i = 0 
... called from f:\phix\p.exw:2528 in function main() 
    savepath = `f:\phix\out` 
    outfile = <novalue> 
    CSvaddr4 = 2826282 
    ebp4 = 150825 
    esp4 = 114673 
    pst4 = 1058085 
    ntcb4 = <novalue> 
    wasEBP = 0 
    pi = <novalue> 
    dfn = <novalue> 
    i = <novalue> 
    i = <novalue> 
    paramstr = <novalue> 
    i = <novalue> 
... called from f:\phix\p.exw:2853 

The ex. err file is very large, I sent it to Pete

new topic     » goto parent     » topic index » view message » categorize

3. Re: Oddities in pipeio

std/pipeio.e is a Euphoria file, not Phix. The std/ directory is shipped with Phix in the hope some things might be useful, in this case not [1].

Instead, on Phix, take a look at demo\capture_console.exw - messy and incomplete and undocumented, but I just tried "dir" and it worked fine (on Windows 10 anyway[2]).

Continue this discussion here, and I'll work with you to get these things properly documented and into /builtins where they belong.

Note that create_pipe(), close_handle() and the like are intended to become global whereas WriteToPipe(), ReadFromPipe() and other camelcase routines are intended to remain private/internal.

[1] Very few ever are. There's a "*NOT PHIX COMPATIBLE!*" thing at the top of std/map.e, quite probably there should be one at the top of std/pipeio.e as well.
[2] Be warned that if there are any major stumbling blocks therein, I will just walk away rather than waste much time specifically supporting Windows XP, much as I like it, it's dead.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Oddities in pipeio

Thank you, capture_console.exw in Windows XP works without problems, and the code is very chaotic, I'm afraid that I myself will not be able to make a library out of it.

p.s. Perhaps I will say something stupid, but it can make 2 library files for Windows and Linux OS and connect them by condition, for example:

if platform()=WINDOWS then include pipeio_w.e else pipeio_l.e.
new topic     » goto parent     » topic index » view message » categorize

5. Re: Oddities in pipeio

AlexXX said...

Thank you, capture_console.exw in Windows XP works without problems

Good to know, that's my biggest worry gone.

AlexXX said...

the code is very chaotic, I'm afraid that I myself will not be able to make a library out of it.

I didn't expect you to. I'll make a start by extracting code from capture_console.exw to a new builtins/pipeio.e here and getting that all working.
I will let you know when I've finished (the first round of) those changes and uploaded them to github. I might even make a start on the docs.
You are the first person (in recent times) that has expressed a need for this, in Phix, which is why it has not already been done, is all.

AlexXX said...

p.s. Perhaps I will say something stupid, but it can make 2 library files for Windows and Linux OS and connect them by condition, for example:

if platform()=WINDOWS then include pipeio_w.e else pipeio_l.e.

You're quite right, that's not the best suggestion. blink
Don't worry about it, it is my job to make a single builtins/pipeio.e that can be used seamlessly, and with no significant efficiency or binary output size overheads.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Oddities in pipeio

I have uploaded a new builtins\pipeio.e along with pipeio.htm, and updated demo\capture_console.exw in the repository.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu