diff options
author | Lukas Larsson <[email protected]> | 2018-02-28 10:04:53 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2018-03-21 17:52:43 +0100 |
commit | 5a583d0e58a97038f5fa3bdfa3c35694f0a18f34 (patch) | |
tree | a7efc12ac5cc2ddff77bba1c152b9c02c8dfd8be | |
parent | b6df9b6babb5002c5eb940e27474855abf4c5930 (diff) | |
download | otp-5a583d0e58a97038f5fa3bdfa3c35694f0a18f34.tar.gz otp-5a583d0e58a97038f5fa3bdfa3c35694f0a18f34.tar.bz2 otp-5a583d0e58a97038f5fa3bdfa3c35694f0a18f34.zip |
kernel: Fix handling of os:cmd option max_size in win
git cherry-pick 75b0f73f72e1783d4ace976cdd2b5f23bdc3ebae
-rw-r--r-- | lib/kernel/src/os.erl | 8 | ||||
-rw-r--r-- | lib/kernel/test/os_SUITE.erl | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl index dbb28c1210..92ac401b72 100644 --- a/lib/kernel/src/os.erl +++ b/lib/kernel/src/os.erl @@ -310,16 +310,16 @@ get_data(Port, MonRef, Eot, Sofar, Size, Max) -> iolist_to_binary(Sofar) end. -eot(_Bs, <<>>, _Size, _Max) -> +eot(Bs, <<>>, Size, Max) when Size + byte_size(Bs) < Max -> more; +eot(Bs, <<>>, Size, Max) -> + binary:part(Bs, {0, Max - Size}); eot(Bs, Eot, Size, Max) -> case binary:match(Bs, Eot) of - nomatch when Size + byte_size(Bs) < Max -> - more; {Pos, _} when Size + Pos < Max -> binary:part(Bs,{0, Pos}); _ -> - binary:part(Bs,{0, Max - Size}) + eot(Bs, <<>>, Size, Max) end. %% When port_close returns we know that all the diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl index 70752e6ee6..cfd475becf 100644 --- a/lib/kernel/test/os_SUITE.erl +++ b/lib/kernel/test/os_SUITE.erl @@ -324,8 +324,8 @@ max_size_command(_Config) -> Res32768 = os:cmd("cat /dev/zero", #{ max_size => 32768 }), 32768 = length(Res32768), - ResHello = os:cmd("echo hello", #{ max_size => 20 }), - 6 = length(ResHello). + ResHello = string:trim(os:cmd("echo hello", #{ max_size => 20 })), + 5 = length(ResHello). %% Test that the os:perf_counter api works as expected perf_counter_api(_Config) -> |