/
pipe-stdout.t
1007 lines (832 loc) · 23.9 KB
/
pipe-stdout.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# vim:set ft= ts=4 sw=4 et fdm=marker:
use lib '.';
use t::TestCore;
use Cwd qw(abs_path realpath cwd);
use File::Basename;
repeat_each(2);
plan tests => repeat_each() * (blocks() * 3 + 6);
add_block_preprocessor(sub {
my $block = shift;
my $http_config = $block->http_config || '';
my $init_by_lua_block = $block->init_by_lua_block || '';
$http_config .= <<_EOC_;
lua_package_path '$t::TestCore::lua_package_path';
init_by_lua_block {
$t::TestCore::init_by_lua_block
$init_by_lua_block
}
_EOC_
$block->set_value("http_config", $http_config);
if (!defined $block->error_log) {
$block->set_value("no_error_log", "[error]");
}
if (!defined $block->request) {
$block->set_value("request", "GET /t");
}
});
$ENV{TEST_NGINX_CERT_DIR} ||= dirname(realpath(abs_path(__FILE__)));
my $port = server_port;
if ($port < 65535) {
$port++;
} else {
$port--;
}
$ENV{TEST_NGINX_SERVER_SSL_PORT} = $port;
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
env_to_nginx("PATH");
no_long_string();
run_tests();
__DATA__
=== TEST 1: read process, pattern is read line
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
local data, err = proc:stdout_read_line()
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
hello world
=== TEST 2: read process, read line without line break
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "-n", "hello world"})
local data, err, partial = proc:stdout_read_line()
if not data then
ngx.say(err)
ngx.say(partial)
else
ngx.say(data)
end
}
}
--- response_body
closed
hello world
=== TEST 3: read process, pattern is read bytes
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
local data, err = proc:stdout_read_bytes(5)
if not data then
ngx.say(err)
else
ngx.say(data)
end
data, err = proc:stdout_read_bytes(6)
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
hello
world
=== TEST 4: read process, bytes length is zero
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
local data, err = proc:stdout_read_bytes(0)
if not data then
ngx.say(err)
else
ngx.say("data:", data)
end
}
}
--- response_body
data:
=== TEST 5: read process, bytes length is less than zero
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
local ok, err = pcall(proc.stdout_read_bytes, proc, -1)
if not ok then
ngx.say(err)
end
}
}
--- response_body
bad len argument
=== TEST 6: read process, bytes length is more than data
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
local data, err = proc:stdout_read_bytes(20)
if not data then
ngx.say(err)
else
ngx.say("data:", data)
end
}
}
--- response_body
closed
=== TEST 7: read process, pattern is read all
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "echo -n hello && sleep 0.05 && echo -n world"})
local data, err = proc:stdout_read_all()
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
helloworld
=== TEST 8: read process, pattern is read any
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "echo -n hello && sleep 0.05 && echo -n world"})
-- increase timeout to ensure read_any could return before timeout
proc:set_timeouts(5000, 5000, 5000, nil)
local data, err = proc:stdout_read_any(1024)
if not data then
ngx.say(err)
else
ngx.say(data)
end
data, err = proc:stdout_read_any(1024)
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
hello
world
=== TEST 9: read process, pattern is read any, with limited, max <= 0
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "echo -n hello && sleep 0.05 && echo -n world"})
local ok, err = pcall(proc.stdout_read_any, proc, 0)
if not ok then
ngx.say(err)
end
}
}
--- response_body
bad max argument
=== TEST 10: read process, pattern is read any, with limited, limit larger than read data
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "echo -n hello && sleep 0.05 && echo -n world"})
local data, err = proc:stdout_read_any(1024)
if not data then
ngx.say(err)
else
ngx.say(data)
end
data, err = proc:stdout_read_any(512)
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
hello
world
=== TEST 11: read process, pattern is read any, with limited, limit smaller than read data
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "echo -n hello && sleep 0.05 && echo -n world"})
local data, err = proc:stdout_read_any(4)
if not data then
ngx.say(err)
else
ngx.say(data)
end
data, err = proc:stdout_read_any(3)
if not data then
ngx.say(err)
else
ngx.say(data)
end
data, err = proc:stdout_read_any(1024)
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
hell
o
world
=== TEST 12: read process, without yield
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
ngx.sleep(0.05)
local data, err = proc:stdout_read_line()
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
hello world
=== TEST 13: read process, without yield, get partial data
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "-n", "hello world"})
ngx.sleep(0.05)
local data, err, partial = proc:stdout_read_line()
if not data then
ngx.say(err)
ngx.say(partial)
else
ngx.say(data)
end
}
}
--- response_body
closed
hello world
=== TEST 14: read process, without yield, pattern is read bytes
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
ngx.sleep(0.05)
local data, err = proc:stdout_read_bytes(9)
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
hello wor
=== TEST 15: read process, without yield, pattern is read all
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "echo hello && echo world"})
ngx.sleep(0.05)
local data, err = proc:stdout_read_all()
if not data then
ngx.say(err)
else
ngx.print(data)
end
}
}
--- response_body
hello
world
=== TEST 16: read process, without yield, pattern is read any
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "echo -n hello && sleep 0.01 && echo -n world"})
ngx.sleep(0.05)
local data, err = proc:stdout_read_any(1024)
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
helloworld
=== TEST 17: read process, without yield, read more data than preallocated buffer
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local s = ("0123"):rep(1024)
local proc = ngx_pipe.spawn({"echo", "-n", s})
ngx.sleep(0.05)
local data, err = proc:stdout_read_all()
if not data then
ngx.say(err)
elseif data ~= s then
ngx.say("actual read:", data)
else
ngx.say("ok")
end
}
}
--- response_body
ok
=== TEST 18: read process, without yield, read more partial data than preallocated buffer
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local s = ("0123"):rep(1024)
local proc = ngx_pipe.spawn({"echo", "-n", s})
ngx.sleep(0.05)
local data, err, partial = proc:stdout_read_line()
if not data then
ngx.say(err)
if partial ~= s then
ngx.say("actual read:", data)
else
ngx.say("ok")
end
end
}
}
--- response_body
closed
ok
=== TEST 19: read process, with yield, read more data than preallocated buffer
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local s = ("0123"):rep(1024)
local proc = ngx_pipe.spawn({"echo", "-n", s})
local data, err = proc:stdout_read_all()
if not data then
ngx.say(err)
elseif data ~= s then
ngx.say("actual read:", data)
else
ngx.say("ok")
end
}
}
--- response_body
ok
--- no_error_log
[error]
--- error_log
lua pipe read yielding
=== TEST 20: read process, with yield, read more partial data than preallocated buffer
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local s = ("0123"):rep(1024)
local proc = ngx_pipe.spawn({"echo", "-n", s})
local data, err, partial = proc:stdout_read_line()
if not data then
ngx.say(err)
if partial ~= s then
ngx.say("actual read:", data)
else
ngx.say("ok")
end
end
}
}
--- no_error_log
[error]
--- error_log
lua pipe read yielding
--- response_body
closed
ok
=== TEST 21: read process, mix read pattern
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local script = [[
echo -n hello
sleep 0.1
echo world
echo more
sleep 0.1
echo -n da
sleep 0.1
echo -n ta
]]
local proc = ngx_pipe.spawn({"sh", "-c", script})
local function check_call(proc, func, ...)
local data, err = func(proc, ...)
if not data then
ngx.say(err)
ngx.exit(ngx.OK)
end
ngx.say(data)
end
ngx.say("reading any")
check_call(proc, proc.stdout_read_any, 1024)
ngx.say("reading 3")
check_call(proc, proc.stdout_read_bytes, 3)
ngx.say("reading line")
check_call(proc, proc.stdout_read_line)
ngx.say("reading 2")
check_call(proc, proc.stdout_read_bytes, 2)
ngx.say("reading any")
check_call(proc, proc.stdout_read_any, 1024)
ngx.say("reading all")
check_call(proc, proc.stdout_read_all)
}
}
--- response_body
reading any
hello
reading 3
wor
reading line
ld
reading 2
mo
reading any
re
reading all
data
=== TEST 22: read process, no data to read
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sleep", 0.01})
local data, err = proc:stdout_read_any(1024)
if not data then
ngx.say(err)
else
ngx.say("data:", data)
end
}
}
--- response_body
closed
=== TEST 23: read process, no data to read, use read all
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sleep", 0.01})
local data, err = proc:stdout_read_all()
if not data then
ngx.say(err)
else
ngx.say("data:", data)
end
}
}
--- response_body
data:
=== TEST 24: read process after waiting
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
local ok, err = proc:wait()
if not ok then
ngx.say("wait failed: ", err)
return
end
local data, err = proc:stdout_read_line()
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
closed
=== TEST 25: more than one coroutines read a process
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "sleep 0.1 && echo hello && echo world"})
local function read()
local data, err = proc:stdout_read_line()
if not data then
ngx.say(err)
else
ngx.say(data)
end
end
local th1 = ngx.thread.spawn(read)
local th2 = ngx.thread.spawn(read)
ngx.thread.wait(th1)
ngx.thread.wait(th2)
ngx.thread.spawn(read)
}
}
--- response_body
pipe busy reading
hello
world
=== TEST 26: read process, timeout
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sleep", "10s"})
proc:set_timeouts(nil, 100)
local ok, err = proc:stdout_read_line()
if not ok then
ngx.say(err)
else
ngx.say("ok")
end
}
}
--- response_body
timeout
--- no_error_log
[error]
--- error_log
lua pipe add timer for reading: 100(ms)
=== TEST 27: read process, aborted by uthread kill
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sh", "-c", "sleep 0.1 && echo hello"})
local function read()
proc:stdout_read_line()
ngx.log(ngx.ERR, "can't reach here")
end
local th = ngx.thread.spawn(read)
ngx.thread.kill(th)
local data, err = proc:stdout_read_line()
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
--- response_body
hello
--- no_error_log
[error]
--- error_log
lua pipe read process:
lua pipe proc read stdout cleanup
=== TEST 28: read process while waiting process in other request
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
package.loaded.proc = ngx_pipe.spawn({"sh", "-c", "sleep 0.01 && echo hello world && exit 2"})
local res1 = ngx.location.capture("/req1")
local res2 = ngx.location.capture("/req2")
ngx.print(res1.body)
ngx.print(res2.body)
}
}
location = /req1 {
content_by_lua_block {
local data, err = package.loaded.proc:stdout_read_line()
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
location = /req2 {
content_by_lua_block {
local ok, reason, status = package.loaded.proc:wait()
if not ok then
ngx.say(reason)
ngx.say(status)
end
}
}
--- response_body
hello world
exit
2
=== TEST 29: read process while waiting process in other request, return error
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
package.loaded.proc = ngx_pipe.spawn({"sh", "-c", "sleep 10s"})
local res1, res2 = ngx.location.capture_multi{{"/req1"}, {"/req2"}}
ngx.print(res1.body)
ngx.print(res2.body)
}
}
location = /req1 {
content_by_lua_block {
local proc = package.loaded.proc
proc:set_timeouts(nil, 100)
local data, err = proc:stdout_read_line()
if not data then
ngx.say(err)
else
ngx.say(data)
end
}
}
location = /req2 {
content_by_lua_block {
local proc = package.loaded.proc
-- sleep to ensure proc is already spawned under Valgrind
ngx.sleep(0.2)
os.execute("kill -TERM " .. proc:pid())
local ok, reason, status = proc:wait()
if not ok then
ngx.say(reason)
ngx.say(status)
end
}
}
--- response_body
timeout
signal
15
=== TEST 30: user case with read and wait
--- no_checke_leak
--- http_config
server {
listen $TEST_NGINX_SERVER_SSL_PORT ssl;
server_name test.com;
ssl_certificate $TEST_NGINX_CERT_DIR/cert/test.crt;
ssl_certificate_key $TEST_NGINX_CERT_DIR/cert/test.key;
}
--- config
lua_ssl_trusted_certificate $TEST_NGINX_CERT_DIR/cert/test.crt;
location /t {
set $addr 127.0.0.1:$TEST_NGINX_SERVER_SSL_PORT;
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local addr = ngx.var.addr;
local f, err = ngx_pipe.spawn({"sh", "-c", "echo 'Q' | openssl s_client -connect " .. addr})
if not f then
ngx.say(err)
return
end
local out = f:stdout_read_all()
if out:find("CONNECTED", 1, true) ~= 1 then
ngx.say("could not find CONNECTED in output: ", out)
local stderr_out = f:stderr_read_all()
ngx.say("the message from stderr is: ", stderr_out)
return
end
local ok, reason = f:wait()
if not ok then
ngx.say(reason)
else
ngx.say('ok')
ngx.say(reason)
end
}
}
--- response_body
ok
exit
=== TEST 31: ensure reading process in phases without yield support is disabled
--- http_config
init_worker_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
local ok, err = pcall(proc.stdout_read_line, proc)
if not ok then
package.loaded.res = err
end
}
--- config
location = /t {
content_by_lua_block {
ngx.say(package.loaded.res)
}
}
--- response_body_like
.+ API disabled in the context of init_worker_by_lua\*
=== TEST 32: but we could spawn it in init_worker_by_lua and read it later
--- http_config
init_worker_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"echo", "hello world"})
package.loaded.proc = proc
}
--- config
location = /t {
content_by_lua_block {
local proc = package.loaded.proc
if proc then
local data, err = proc:stdout_read_line()
if not data then
ngx.say(err)
else
ngx.say(data)
end
-- we could only read once as we only spawn the proess once
package.loaded.proc = nil
else
-- so just return the expected data in repeated tests.
ngx.say("hello world")
end
}
}
--- response_body
hello world
=== TEST 33: read process, aborted by uthread kill, with graceful shutdown
--- user_files
>>> a.lua
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"bash"})
local function func()
proc:stdout_read_line()
ngx.log(ngx.ERR, "can't reach here")
end
local th = ngx.thread.spawn(func)
ngx.thread.kill(th)
local data, err = proc:kill(9) -- SIGKILL
if not data then
io.stdout:write("proc:kill(9) err: ", err)
else
io.stdout:write("ok")
end
--- config
location = /t {
content_by_lua_block {
local helper = require "helper"
local f = io.open("$TEST_NGINX_HTML_DIR/a.lua")
local code = f:read("*a")
local proc = helper.run_lua_with_graceful_shutdown("$TEST_NGINX_HTML_DIR", code)
proc:set_timeouts(100, 100, 100, 100)
local data, err = proc:stdout_read_all()
if not data then
ngx.say("stdout err: ", err)
else
ngx.say("stdout: ", data)
end
local data, err = proc:stderr_read_any(4096)
if not data then
ngx.say("stderr err: ", err)
else
ngx.say("stderr: ", data)
end
}
}
--- response_body
stdout: ok
stderr err: closed
--- no_error_log
[error]
=== TEST 34: spawn process with stdout_read_timeout option
--- config
location = /t {
content_by_lua_block {
local ngx_pipe = require "ngx.pipe"
local proc = ngx_pipe.spawn({"sleep", "10s"}, {
stdout_read_timeout = 100
})
local data, err = proc:stdout_read_line()
if not data then
ngx.say("stdout err: ", err)
else
ngx.say("stdout: ", data)
end
}