lua-users home
lua-l archive

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


Subject: Problem using posix library pipe() from luajit2?
Reply-To: dslate@speakeasy.net
To: lua-l@lists.lua.org

I am having a problem trying to use the posix library pipe() function from
LuaJIT 2.0.0-beta6.  The same code works in regular Lua 5.1.4.  It seems
that with LuaJIT, the types of the values returned by pipe() seem to be
getting confused somehow.

The script log below illustrates the problem, which seems to occur on both
openSUSE and Ubuntu flavors of Linux.  Any ideas on what's going wrong?

Thanks,

-- Dave Slate


Script started on Sun Mar 27 00:43:47 2011
dave@faith2:~/lua> cat pipetst.lua
#!/usr/local/bin/lua -v

local ox = require( "posix")
local rd, wr = ox.pipe()
print( type( rd), type( wr), ox.version)
wr:write( "blah\n")
print( "After wr:write, before wr:close")
io.flush()
wr:close()
print( "After wr:close, before rd:read")
io.flush()
print( rd:read())
rd:close()
dave@faith2:~/lua> 
dave@faith2:~/lua> ./pipetst.lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
userdata	userdata	posix library for Lua 5.1 / 5.1.9
After wr:write, before wr:close
After wr:close, before rd:read
blah
dave@faith2:~/lua> 
dave@faith2:~/lua> cat pipetst.luajit
#!/usr/local/bin/luajit -v

local ox = require( "posix")
local rd, wr = ox.pipe()
print( type( rd), type( wr), ox.version)
wr:write( "blah\n")
print( "After wr:write, before wr:close")
io.flush()
wr:close()
print( "After wr:close, before rd:read")
io.flush()
print( rd:read())
rd:close()
dave@faith2:~/lua>
dave@faith2:~/lua> diff pipetst.lua pipetst.luajit
1c1
< #!/usr/local/bin/lua -v
---
> #!/usr/local/bin/luajit -v
dave@faith2:~/lua> 
dave@faith2:~/lua> ./pipetst.luajit
LuaJIT 2.0.0-beta6 -- Copyright (C) 2005-2011 Mike Pall. http://luajit.org/
userdata	userdata	posix library for Lua 5.1 / 5.1.9
/usr/local/bin/luajit: bad argument #1 to '?' (FILE* expected, got userdata)
dave@faith2:~/lua> exit

Script done on Sun Mar 27 00:47:00 2011