I'm using the luajit ffi library to call into the C library function waitpid.
However I can't find a proper specification for the encoding of the status result. The only documentation I've found are C macro functions I'd prefer to write in pure lua.
I had a brief look at the header files defining these macro's and would you know it, they are not simple but refer to other macros which refer to still other macros.
Can you help?
One way is to wrap the macros in little functions:
#include <sys/types.h>
#include <sys/wait.h>
int wifexited(int status) {
return WIFEXITED(status);
}
int wifexitstatus(int status) {
return WEXITSTATUS(status);
}
Now build a DLL (you didn't mention OS, so you'll have to work that out yourself).
Load the DLL ffi.load(...)
and finally:
waitpidlib = ffi.cdef[[
int wifexited(int status);
int wifexitstatus(int status);
]]
...
local ans = waidpidlib.wifexited(42)