aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-03-02 10:18:34 +0100
committerLukas Larsson <[email protected]>2018-03-02 10:18:34 +0100
commit5d4267657b2ef41d33cfd6ed920186bcf215d520 (patch)
tree84471426bfb9a02060345fb72319a73f0a90bfec /lib/kernel
parent73fc86ea0c79f4b1fbc434ba4261345b6d6e772f (diff)
parentfb218aaf3ef9da8f21a95f7e5a96e0210812d04b (diff)
downloadotp-5d4267657b2ef41d33cfd6ed920186bcf215d520.tar.gz
otp-5d4267657b2ef41d33cfd6ed920186bcf215d520.tar.bz2
otp-5d4267657b2ef41d33cfd6ed920186bcf215d520.zip
Merge branch 'maint'
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/src/os.erl8
-rw-r--r--lib/kernel/test/os_SUITE.erl4
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl
index 1e9db80058..77c883f57f 100644
--- a/lib/kernel/src/os.erl
+++ b/lib/kernel/src/os.erl
@@ -358,16 +358,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 4369b1b0f9..591fbb2125 100644
--- a/lib/kernel/test/os_SUITE.erl
+++ b/lib/kernel/test/os_SUITE.erl
@@ -334,8 +334,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) ->