jmckaskill / luaffi

Standalone FFI library for calling C functions from lua. Compatible with the luajit FFI interface.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sigaction

jmckaskill opened this issue · comments

Getting confused with a struct and function having the same name?

> S.sigaction( S.SIGINT, function(sig) g_terminated = true end )
lua: unable to convert argument 8 from lua<table> to cdata<uint64_t>
stack traceback:
   [C]: in function 'sigaction_t'
   ./io/syscall.lua:2880: in function 'sigaction'

@justincormack Did you change something so that this now works?

james@hawea ~/c/luaffi $ lua                                                master 
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> S = require 'syscall'
> S.sigaction(S.SIGINT, function(sig) g_terminated = true end)
> 

Yes, have been fixing up all the easy stuff to get ljsyscall to work with luaffi...

Do you remember what you changed, just so I can fix luaffi?

It was this commit

justincormack/ljsyscall@45a08c5#syscall.lua

stringflag returns a number, S.t.sighandler is sighandler_t ie a function pointer type.

So this is the same as existing issues I think.

Even if I go back to before that commit on ljsyscall and to 1.0-work1 on luaffi I still can't get it to fail. Looking at the code around it in ljsyscall in looks like a ffi.cast call creating a struct where the args are pre-expanded.

Thus I'm going to class this as a dup of #25.