lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

  I have a strange behavior with the popen function when I use it with luajava on winXP 32bit.(On linux no problem detected).

 

  I use the luajava eclipse plugin, and try to execute this code (in a plugin Junit Test case) :

 

===============================================

Junit Test case :

@Test

public void popen()

{

      l.getGlobal("require");

      l.pushString("tests.simpletest");

      if (l.pcall( 1, 1, 0) != 0)

        l.error();

      l.pop(-1);

 

      l.getGlobal("popenTest");

      if (l.pcall( 0, 0, 0) != 0)

        l.error();

}

===============================================

Lua Test File :

function popenTest()

     print (_VERSION)

     print("test started !")

     p,msg = io.popen('dir');

     if not p then error("popen (dir) return nil. msg : ".. tostring(msg)) end

     print ("p : ".. tostring(p))

     l,msg = p:read("*l");

     if not l then error("read (popen (dir)) return nil. msg :".. tostring(msg)) end

     print (l)

     print("test done !")

end

===============================================

And I get this result :

Lua 5.1

test started !

p : file (18EE1AA0)

PANIC: unprotected error in call to Lua API (...project.luaeclipse.lua.test\lua\tests\simpletest.lua:7: read (popen (dir)) return nil. msg :nil) ===============================================

 

I try with p:read(1) instead of p:read(“*l”), and I get the same result.

I also try with p:read(“*a”) and I get :

Lua 5.1

test started !

p : file (18EE1AA0)

 

test done !

 

I try with another command than ‘dir’ like ‘echo toto’ or with  my own executable and a fullpath reference to it. I get the same problem.

When I try without luajava, this works well.

 

It seems this is a bug, if  you have any idea to solve this problem ? (or perhaps a workaround ?)

 

Thanks you.

 

Simon