Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ install:
- git clone https://github.com/openresty/nginx-devel-utils.git
- git clone https://github.com/openresty/lua-nginx-module.git ../lua-nginx-module
- git clone https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx
- git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git
- git clone -b fix/eintr https://github.com/thibaultcha/luajit2.git

script:
- cd luajit2/
Expand Down
33 changes: 33 additions & 0 deletions t/resty/sanity.t
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,36 @@ hello
world
--- err
--- ret: 0



=== TEST 6: catch interrupted fread during file readall (GH issue #35)
--- src
local ffi = require "ffi"

ffi.cdef [[
int getpid(void);
]]

local pid = ffi.C.getpid()

local signal = 17
local platform = assert(io.popen("uname"):read("*l"))
if platform == "Darwin" then
signal = 0
end

local cmd = string.format("kill -%d %d && sleep 0.1", signal, pid)
assert(io.popen(cmd):read("*a"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we could add a test case for the case when the underlying read() syscall encounters an error other than EINTR. But it seems tricky without the help of special instrumenting facility like gdb or systemtap :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found a way! See the latest patch.

--- err
--- ret: 0



=== TEST 7: file readall returns syscall errno when not EINTR (GH issue #35)
--- src
local f = assert(io.open("/"))
assert(f:read("*a"))
--- err_like chomp
^ERROR:.*?\.lua:2: Is a directory$
--- ret: 1