aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/os.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2016-09-05 17:08:51 +0200
committerLukas Larsson <[email protected]>2016-09-05 17:08:51 +0200
commitcf88d37535e889adb5252c4110d53f5a4fd7f5b9 (patch)
tree5a2d74e98beb2963bb33601056a0aadc13625c80 /lib/kernel/src/os.erl
parent1687a793055708854911fd466b4eb5bbb32e2a70 (diff)
parentbb8d105fd6d5b09097dc64b341d63f0f8d7e8906 (diff)
downloadotp-cf88d37535e889adb5252c4110d53f5a4fd7f5b9.tar.gz
otp-cf88d37535e889adb5252c4110d53f5a4fd7f5b9.tar.bz2
otp-cf88d37535e889adb5252c4110d53f5a4fd7f5b9.zip
Merge branch 'maint'
Diffstat (limited to 'lib/kernel/src/os.erl')
-rw-r--r--lib/kernel/src/os.erl14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl
index 05bbf1069e..f8519d3a5e 100644
--- a/lib/kernel/src/os.erl
+++ b/lib/kernel/src/os.erl
@@ -254,7 +254,19 @@ mk_cmd(_,Cmd) ->
{"/bin/sh -s unix:cmd", [out],
%% We insert a new line after the command, in case the command
%% contains a comment character.
- ["(", unicode:characters_to_binary(Cmd), "\n); echo \"\^D\"\n"],
+ %%
+ %% The </dev/null closes stdin, which means that programs
+ %% that use a closed stdin as an termination indicator works.
+ %% An example of such a program is 'more'.
+ %%
+ %% The "echo ^D" is used to indicate that the program has executed
+ %% and we should return any output we have gotten. We cannot use
+ %% termination of the child or closing of stdin/stdout as then
+ %% starting background jobs from os:cmd will block os:cmd.
+ %%
+ %% I tried changing this to be "better", but got bombarded with
+ %% backwards incompatibility bug reports, so leave this as it is.
+ ["(", unicode:characters_to_binary(Cmd), "\n) </dev/null; echo \"\^D\"\n"],
<<$\^D>>}.
validate(Atom) when is_atom(Atom) ->