Skip to content

Commit df3dd35

Browse files
tests: added a test for ngx.pipe to cover the pipe reading.
ngx.pipe forgot to close pipe after dup2 which make the output pipe won't be close for the child process which is a daemon. So the nginx will never get the close event for the pipe.
1 parent 3394c39 commit df3dd35

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ addons:
1818
- cpanminus
1919
- axel
2020
- luarocks
21+
- daemonize
2122

2223
cache:
2324
directories:

t/pipe-stdout.t

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,3 +1005,25 @@ stdout err: timeout
10051005
lua pipe add timer for reading: 100(ms)
10061006
--- no_error_log
10071007
[error]
1008+
1009+
1010+
1011+
=== TEST 35: start a daemon process
1012+
--- config
1013+
location = /t {
1014+
content_by_lua_block {
1015+
local ngx_pipe = require "ngx.pipe"
1016+
local proc = ngx_pipe.spawn({"sh", "-c", "daemonize /usr/bin/sleep 30 >/dev/null 2>&1"})
1017+
1018+
local data, err = proc:stdout_read_all()
1019+
if not data then
1020+
ngx.say(err)
1021+
end
1022+
1023+
ngx.say("OK")
1024+
}
1025+
}
1026+
--- response_body
1027+
OK
1028+
--- no_error_log
1029+
[error]

0 commit comments

Comments
 (0)