Skip to content

Commit

Permalink
Update tty article; fix run.fish
Browse files Browse the repository at this point in the history
  • Loading branch information
nazmulidris committed Aug 25, 2024
1 parent a406693 commit 279313a
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
12 changes: 6 additions & 6 deletions _posts/2024-08-20-tty-linux-async-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ categories:
- [What is the relationship between linux shells, subshells, and fork, exec, and wait patterns?](#what-is-the-relationship-between-linux-shells-subshells-and-fork-exec-and-wait-patterns)
- [Does exec change the current working directory or affect environment variables in the parent?](#does-exec-change-the-current-working-directory-or-affect-environment-variables-in-the-parent)
- [Then how does the cd command change the current working directory of a shell?](#then-how-does-the-cd-command-change-the-current-working-directory-of-a-shell)
- [How do subshells work, in the case where I don't the shell's environment to be affected at all?](#how-do-subshells-work-in-the-case-where-i-dont-the-shells-environment-to-be-affected-at-all)
- [How do subshells work, in the case where I dont the shells environment to be affected at all?](#how-do-subshells-work-in-the-case-where-i-dont-the-shells-environment-to-be-affected-at-all)
- [Deep dive of all this information in video format](#deep-dive-of-all-this-information-in-video-format)
- [Processes, sessions, jobs, PTYs, signals using C](#processes-sessions-jobs-ptys-signals-using-c)
- [What is /dev/tty?](#what-is-devtty)
Expand Down Expand Up @@ -493,7 +493,7 @@ you do this? This is where subshells come into play. If you're using `fish`, the
running `fish -c` with whatever is typed in between `""`.

##### How do subshells work, in the case where I don't the shell's environment to be affected at all?
<a id="markdown-how-do-subshells-work%2C-in-the-case-where-i-don't-the-shell's-environment-to-be-affected-at-all%3F" name="how-do-subshells-work%2C-in-the-case-where-i-don't-the-shell's-environment-to-be-affected-at-all%3F"></a>
<a id="markdown-how-do-subshells-work%2C-in-the-case-where-i-don%E2%80%99t-the-shell%E2%80%99s-environment-to-be-affected-at-all%3F" name="how-do-subshells-work%2C-in-the-case-where-i-don%E2%80%99t-the-shell%E2%80%99s-environment-to-be-affected-at-all%3F"></a>

In a Linux shell, a subshell is a separate instance of the shell that is spawned to execute a
command or a group of commands. When a user types a command to execute, the shell creates a subshell
Expand Down Expand Up @@ -861,17 +861,17 @@ async fn main() -> miette::Result<()> {
Here are some notes on the code:
- `tokio::signal::ctrl_c` is a utility function that creates a future that completes
when `ctrl-c` is pressed. There is no need to write a signal stream for this like
when `ctrl-c` is pressed. There is **NO** need to write a signal stream for this like
so:
```rust
let signal = tokio::signal::unix::SignalKind::interrupt();
let mut stream_sigterm =
tokio::signal::unix::signal(
tokio::signal::unix::SignalKind::terminate())
tokio::signal::unix::signal(signal)
.into_diagnostic()?;
loop {
tokio::select! {
_ = stream_sigterm.recv() => {
println!("\nSIGTERM received");
println!("\nSIGINT received");
break;
}
}
Expand Down
12 changes: 6 additions & 6 deletions docs/2024/08/20/tty-linux-async-rust/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ <h5 id="how-do-subshells-work-in-the-case-where-i-dont-the-shells-environment-to

</h5>

<p><a id="markdown-how-do-subshells-work%2C-in-the-case-where-i-don't-the-shell's-environment-to-be-affected-at-all%3F" name="how-do-subshells-work%2C-in-the-case-where-i-don't-the-shell's-environment-to-be-affected-at-all%3F"></a></p>
<p><a id="markdown-how-do-subshells-work%2C-in-the-case-where-i-don%E2%80%99t-the-shell%E2%80%99s-environment-to-be-affected-at-all%3F" name="how-do-subshells-work%2C-in-the-case-where-i-don%E2%80%99t-the-shell%E2%80%99s-environment-to-be-affected-at-all%3F"></a></p>

<p>In a Linux shell, a subshell is a separate instance of the shell that is spawned to execute a
command or a group of commands. When a user types a command to execute, the shell creates a subshell
Expand Down Expand Up @@ -1379,16 +1379,16 @@ <h4 id="example-using-tokio-to-receive-signals">

<ul>
<li><code class="language-plaintext highlighter-rouge">tokio::signal::ctrl_c</code> is a utility function that creates a future that completes
when <code class="language-plaintext highlighter-rouge">ctrl-c</code> is pressed. There is no need to write a signal stream for this like
when <code class="language-plaintext highlighter-rouge">ctrl-c</code> is pressed. There is <strong>NO</strong> need to write a signal stream for this like
so:
<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">let</span> <span class="k">mut</span> <span class="n">stream_sigterm</span> <span class="o">=</span>
<span class="nn">tokio</span><span class="p">::</span><span class="nn">signal</span><span class="p">::</span><span class="nn">unix</span><span class="p">::</span><span class="nf">signal</span><span class="p">(</span>
<span class="nn">tokio</span><span class="p">::</span><span class="nn">signal</span><span class="p">::</span><span class="nn">unix</span><span class="p">::</span><span class="nn">SignalKind</span><span class="p">::</span><span class="nf">terminate</span><span class="p">())</span>
<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">let</span> <span class="n">signal</span> <span class="o">=</span> <span class="nn">tokio</span><span class="p">::</span><span class="nn">signal</span><span class="p">::</span><span class="nn">unix</span><span class="p">::</span><span class="nn">SignalKind</span><span class="p">::</span><span class="nf">interrupt</span><span class="p">();</span>
<span class="k">let</span> <span class="k">mut</span> <span class="n">stream_sigterm</span> <span class="o">=</span>
<span class="nn">tokio</span><span class="p">::</span><span class="nn">signal</span><span class="p">::</span><span class="nn">unix</span><span class="p">::</span><span class="nf">signal</span><span class="p">(</span><span class="n">signal</span><span class="p">)</span>
<span class="nf">.into_diagnostic</span><span class="p">()</span><span class="o">?</span><span class="p">;</span>
<span class="k">loop</span> <span class="p">{</span>
<span class="nn">tokio</span><span class="p">::</span><span class="nd">select!</span> <span class="p">{</span>
<span class="n">_</span> <span class="o">=</span> <span class="n">stream_sigterm</span><span class="nf">.recv</span><span class="p">()</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="nd">println!</span><span class="p">(</span><span class="s">"</span><span class="se">\n</span><span class="s">SIGTERM received"</span><span class="p">);</span>
<span class="nd">println!</span><span class="p">(</span><span class="s">"</span><span class="se">\n</span><span class="s">SIGINT received"</span><span class="p">);</span>
<span class="k">break</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
Expand Down
4 changes: 2 additions & 2 deletions docs/authors/nadiaidris/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<meta property="og:url" content="http://developerlife.com/authors/nadiaidris/" />
<meta property="og:site_name" content="developerlife.com" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2024-08-24T18:59:19-05:00" />
<meta property="article:published_time" content="2024-08-24T23:08:50-05:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Nadiaidris" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2024-08-24T18:59:19-05:00","datePublished":"2024-08-24T18:59:19-05:00","description":"Nadia is a product designer turned web engineer specializing in TypeScript and React.","headline":"Nadiaidris","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/authors/nadiaidris/"},"url":"http://developerlife.com/authors/nadiaidris/"}</script>
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2024-08-24T23:08:50-05:00","datePublished":"2024-08-24T23:08:50-05:00","description":"Nadia is a product designer turned web engineer specializing in TypeScript and React.","headline":"Nadiaidris","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/authors/nadiaidris/"},"url":"http://developerlife.com/authors/nadiaidris/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/assets/main.css" />

Expand Down
4 changes: 2 additions & 2 deletions docs/authors/nazmulidris/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<meta property="og:url" content="http://developerlife.com/authors/nazmulidris/" />
<meta property="og:site_name" content="developerlife.com" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2024-08-24T18:59:19-05:00" />
<meta property="article:published_time" content="2024-08-24T23:08:50-05:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Nazmulidris" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2024-08-24T18:59:19-05:00","datePublished":"2024-08-24T18:59:19-05:00","description":"Nazmul is a software engineer focused on Rust, TUI, Web, and Android technologies.","headline":"Nazmulidris","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/authors/nazmulidris/"},"url":"http://developerlife.com/authors/nazmulidris/"}</script>
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2024-08-24T23:08:50-05:00","datePublished":"2024-08-24T23:08:50-05:00","description":"Nazmul is a software engineer focused on Rust, TUI, Web, and Android technologies.","headline":"Nazmulidris","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/authors/nazmulidris/"},"url":"http://developerlife.com/authors/nazmulidris/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/assets/main.css" />

Expand Down
14 changes: 7 additions & 7 deletions docs/feed.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.3">Jekyll</generator><link href="http://developerlife.com/feed.xml" rel="self" type="application/atom+xml" /><link href="http://developerlife.com/" rel="alternate" type="text/html" /><updated>2024-08-24T18:59:19-05:00</updated><id>http://developerlife.com/feed.xml</id><title type="html">developerlife.com</title><subtitle>Rust, TUI, Android, Web, Desktop, Cloud technologies, and UX engineering and design tutorials.</subtitle><author><name>Nazmul Idris</name></author><entry><title type="html">Build with Naz : Explore Linux TTY, process, signals w/ Rust</title><link href="http://developerlife.com/2024/08/20/tty-linux-async-rust/" rel="alternate" type="text/html" title="Build with Naz : Explore Linux TTY, process, signals w/ Rust" /><published>2024-08-20T10:00:00-05:00</published><updated>2024-08-20T10:00:00-05:00</updated><id>http://developerlife.com/2024/08/20/tty-linux-async-rust</id><content type="html" xml:base="http://developerlife.com/2024/08/20/tty-linux-async-rust/"><![CDATA[<p><img class="post-hero-image" src="/assets/linux-tty-proc-async-rust.svg" /></p>
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.3">Jekyll</generator><link href="http://developerlife.com/feed.xml" rel="self" type="application/atom+xml" /><link href="http://developerlife.com/" rel="alternate" type="text/html" /><updated>2024-08-24T23:08:50-05:00</updated><id>http://developerlife.com/feed.xml</id><title type="html">developerlife.com</title><subtitle>Rust, TUI, Android, Web, Desktop, Cloud technologies, and UX engineering and design tutorials.</subtitle><author><name>Nazmul Idris</name></author><entry><title type="html">Build with Naz : Explore Linux TTY, process, signals w/ Rust</title><link href="http://developerlife.com/2024/08/20/tty-linux-async-rust/" rel="alternate" type="text/html" title="Build with Naz : Explore Linux TTY, process, signals w/ Rust" /><published>2024-08-20T10:00:00-05:00</published><updated>2024-08-20T10:00:00-05:00</updated><id>http://developerlife.com/2024/08/20/tty-linux-async-rust</id><content type="html" xml:base="http://developerlife.com/2024/08/20/tty-linux-async-rust/"><![CDATA[<p><img class="post-hero-image" src="/assets/linux-tty-proc-async-rust.svg" /></p>

<!-- TOC -->

Expand Down Expand Up @@ -521,7 +521,7 @@ you do this? This is where subshells come into play. If you’re using <code cla
running <code class="language-plaintext highlighter-rouge">fish -c</code> with whatever is typed in between <code class="language-plaintext highlighter-rouge">""</code>.</p>

<h5 id="how-do-subshells-work-in-the-case-where-i-dont-the-shells-environment-to-be-affected-at-all">How do subshells work, in the case where I don’t the shell’s environment to be affected at all?</h5>
<p><a id="markdown-how-do-subshells-work%2C-in-the-case-where-i-don't-the-shell's-environment-to-be-affected-at-all%3F" name="how-do-subshells-work%2C-in-the-case-where-i-don't-the-shell's-environment-to-be-affected-at-all%3F"></a></p>
<p><a id="markdown-how-do-subshells-work%2C-in-the-case-where-i-don%E2%80%99t-the-shell%E2%80%99s-environment-to-be-affected-at-all%3F" name="how-do-subshells-work%2C-in-the-case-where-i-don%E2%80%99t-the-shell%E2%80%99s-environment-to-be-affected-at-all%3F"></a></p>

<p>In a Linux shell, a subshell is a separate instance of the shell that is spawned to execute a
command or a group of commands. When a user types a command to execute, the shell creates a subshell
Expand Down Expand Up @@ -979,16 +979,16 @@ them.</p>

<ul>
<li><code class="language-plaintext highlighter-rouge">tokio::signal::ctrl_c</code> is a utility function that creates a future that completes
when <code class="language-plaintext highlighter-rouge">ctrl-c</code> is pressed. There is no need to write a signal stream for this like
when <code class="language-plaintext highlighter-rouge">ctrl-c</code> is pressed. There is <strong>NO</strong> need to write a signal stream for this like
so:
<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">let</span> <span class="k">mut</span> <span class="n">stream_sigterm</span> <span class="o">=</span>
<span class="nn">tokio</span><span class="p">::</span><span class="nn">signal</span><span class="p">::</span><span class="nn">unix</span><span class="p">::</span><span class="nf">signal</span><span class="p">(</span>
<span class="nn">tokio</span><span class="p">::</span><span class="nn">signal</span><span class="p">::</span><span class="nn">unix</span><span class="p">::</span><span class="nn">SignalKind</span><span class="p">::</span><span class="nf">terminate</span><span class="p">())</span>
<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">let</span> <span class="n">signal</span> <span class="o">=</span> <span class="nn">tokio</span><span class="p">::</span><span class="nn">signal</span><span class="p">::</span><span class="nn">unix</span><span class="p">::</span><span class="nn">SignalKind</span><span class="p">::</span><span class="nf">interrupt</span><span class="p">();</span>
<span class="k">let</span> <span class="k">mut</span> <span class="n">stream_sigterm</span> <span class="o">=</span>
<span class="nn">tokio</span><span class="p">::</span><span class="nn">signal</span><span class="p">::</span><span class="nn">unix</span><span class="p">::</span><span class="nf">signal</span><span class="p">(</span><span class="n">signal</span><span class="p">)</span>
<span class="nf">.into_diagnostic</span><span class="p">()</span><span class="o">?</span><span class="p">;</span>
<span class="k">loop</span> <span class="p">{</span>
<span class="nn">tokio</span><span class="p">::</span><span class="nd">select!</span> <span class="p">{</span>
<span class="n">_</span> <span class="o">=</span> <span class="n">stream_sigterm</span><span class="nf">.recv</span><span class="p">()</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="nd">println!</span><span class="p">(</span><span class="s">"</span><span class="se">\n</span><span class="s">SIGTERM received"</span><span class="p">);</span>
<span class="nd">println!</span><span class="p">(</span><span class="s">"</span><span class="se">\n</span><span class="s">SIGINT received"</span><span class="p">);</span>
<span class="k">break</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
Expand Down
3 changes: 2 additions & 1 deletion docs/run.fish
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ function main
bundle install
bundle update

./build-site.fish

if _promptUserForConfirmation "Do you want to run the local dev server"
npm install -g serve
./build-site.fish
killall -9 node # Kill all the node processes (serve runs on node)
serve docs/ & # Run serve in the background, allows `./watch-build.fish` to run in a loop
else
Expand Down
4 changes: 2 additions & 2 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://developerlife.com/authors/nadiaidris/</loc>
<lastmod>2024-08-24T18:59:19-05:00</lastmod>
<lastmod>2024-08-24T23:08:50-05:00</lastmod>
</url>
<url>
<loc>http://developerlife.com/authors/nazmulidris/</loc>
<lastmod>2024-08-24T18:59:19-05:00</lastmod>
<lastmod>2024-08-24T23:08:50-05:00</lastmod>
</url>
<url>
<loc>http://developerlife.com/1998/12/01/xml-and-java-tutorial-part-1/</loc>
Expand Down
3 changes: 2 additions & 1 deletion run.fish
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ function main
bundle install
bundle update

./build-site.fish

if _promptUserForConfirmation "Do you want to run the local dev server"
npm install -g serve
./build-site.fish
killall -9 node # Kill all the node processes (serve runs on node)
serve docs/ & # Run serve in the background, allows `./watch-build.fish` to run in a loop
else
Expand Down

0 comments on commit 279313a

Please sign in to comment.