New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
posix.getpid() doesn't accept any arguments. #231
Comments
|
Hi Karl, Thanks for the report. I can't reproduce your issue, even if I downgrade to v33.2.1: $ luarocks remove luaposix
$ luarocks install luaposix 33.2.1
...
luaposix 33.2.1-1 is now built and installed in /usr/local (license: MIT/X11)
$ lua
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> =require'posix'.version
posix for Lua 5.2 / luaposix 33.2.1
> tostring=require'std'.tostring
> getpid=require'posix'.getpid
> =getpid()
{egid=20,euid=504,gid=20,pgrp=58875,pid=58875,ppid=8578,uid=504}
> =getpid'pid'
58875
> =getpid{'pid'}
58875This also works with latest master. There is no documentation for that behaviour, because it is provided purely for backwards compatibility so as not to surprise clients that use the old APIs. As such it is not documented, in order to encourage the use of the faster new thin wrappers for the functions (getpid etc) from http://luaposix.github.io/luaposix/modules/posix.unistd.html And used like this: $ luarocks install luaposix
...
luaposix 33.3.1-1 is now built and installed in /usr/local (license: MIT/X11)
$ lua
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> =require'posix'.version
posix for Lua 5.2 / luaposix 33.3.1
> unistd=require'posix.unistd'
> =unistd.getpid()
62182
> =unistd.getppid()
8578Cheers, |
|
I wish it were that easy :) Is it possible that luaposix has been mis-packaged in this case? Any tips on how I could check whether luaposix is installed correctly? |
|
Looks like you're missing the lua loader that puts all the backward compatibility shims in place, or your LUA_PATH is missing their install location, or you are picking up bits from mismatched releases somehow If posix.getpid is a C function (can't string.dump it) or is equal to the function at HTH |
|
Yup, the openwrt packaging explicitly excludes the compat and deprecated. (And worse, it was even myself that suggested we could do that, when we saw how big they were) Thanks for looking into this, and I'm sorry for the wild goose chase. |
|
No problem, thanks for letting me know what the underlying issue was. For the record, I think you have taken the right approach, because you have control over all the client code, you can write it to take advantage of the latest and greatest APIs, and jettison all the cruft for supporting slow adopters too :-) |
|
Might I work necromancy on this thread to say: I'm confused - does luaposix allow one to see whether an arbitrary string has a coresponding 'pid', as Linux's |
|
@LinuxOnTheDesktop |
|
@karlp: good point. Surely though luaposix or lua itself provides some fairly straightforward way of checking whether a process is running? |
|
it may, but it's absolutely not the right place to talk about it on this ticket. |
|
Right. I can't seem to find a luaposix IRC or forum, though. |
|
You can start a thread on the regular Lua mailing list if you’d like. There are plenty of ways to get at Linux-only C APIs from Lua, but luaposix is not among them :-) |
In v32, you could use posix.getpid("pid") and posix.getpid("ppid").
in v33, you can only use posix.getpid() and posix.getppid()
However, the NEWS file for v33 says, under "bugs fixed" "posix.getpasswd, posix.getpid, posix.pathconf, posix.stat, posix.statvfs, posix.sysconf and posix.times process a single table argument with a list of types correctly."
v33 (v33.2.1 to be specific) does not allow passing any arguments, table or string or otherwise, into posix.getpid().
I'm fine with it not being backward compatible, but how is it meant to behave? Is there no longer any method to get the full table?
Also, the fact that these are available as posix.getxxx is not documented. They are only described as under posix.unistd.xxxx
The text was updated successfully, but these errors were encountered: