From 24017ad83f52d4adc6ed3a8e187a0879fea7552f Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Tue, 29 May 2018 11:06:31 -0500 Subject: [PATCH] Clarify usage of <<< --- slides/intro/Namespaces_Cgroups.md | 55 +++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/slides/intro/Namespaces_Cgroups.md b/slides/intro/Namespaces_Cgroups.md index c27fae3a..f5819678 100644 --- a/slides/intro/Namespaces_Cgroups.md +++ b/slides/intro/Namespaces_Cgroups.md @@ -808,7 +808,7 @@ $ sudo mkdir $CG Limit it to approximately 100MB of memory usage: ```bash -$ sudo tee $CG/memory.memsw.limit_in_bytes <<<100000000 +$ sudo tee $CG/memory.memsw.limit_in_bytes <<< 100000000 ``` Move the current process to that cgroup: @@ -819,6 +819,59 @@ $ sudo tee $CG/tasks <<< $$ The current process *and all its future children* are now limited. +(Confused about `<<<`? Look at the next slide!) + +--- + +## What's `<<<`? + +- This is a "here string". (It is a non-POSIX shell extension.) + +- The following commands are equivalent: + + ```bash + foo <<< hello + ``` + + ```bash + echo hello | foo + ``` + + ```bash + foo < $CG/tasks" +``` + +The following commands, however, would be invalid: + +```bash +sudo echo $$ > $CG/tasks +``` + +```bash +sudo -i # (or su) +echo $$ > $CG/tasks +``` + --- ## Testing the memory limit