Skip to content

Commit

Permalink
Support android execute
Browse files Browse the repository at this point in the history
  • Loading branch information
chrox committed Apr 22, 2015
1 parent 7de33cf commit d2c5375
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ffi/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,19 @@ function util.realpath(path)
end

function util.execute(...)
local pid = ffi.C.fork()
if pid == 0 then
local args = {...}
os.exit(ffi.C.execl(args[1], unpack(args, 1, #args+1)))
end
local status = ffi.new('int[1]')
ffi.C.waitpid(pid, status, 0)
return status[0]
if util.isAndroid() then
local A = require("android")
return A.execute(...)
else
local pid = ffi.C.fork()
if pid == 0 then
local args = {...}
os.exit(ffi.C.execl(args[1], unpack(args, 1, #args+1)))
end
local status = ffi.new('int[1]')
ffi.C.waitpid(pid, status, 0)
return status[0]
end
end

function util.utf8charcode(charstring)
Expand Down

0 comments on commit d2c5375

Please sign in to comment.