<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Terminal on pemako</title>
    <link>http://pemako.cn/tags/terminal/</link>
    <description>Recent content in Terminal on pemako</description>
    <image>
      <title>pemako</title>
      <url>http://pemako.cn/images/papermod-cover.png</url>
      <link>http://pemako.cn/images/papermod-cover.png</link>
    </image>
    <generator>Hugo -- 0.146.6</generator>
    <language>en</language>
    <lastBuildDate>Thu, 09 Apr 2026 20:00:00 +0800</lastBuildDate>
    <atom:link href="http://pemako.cn/tags/terminal/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>终端原理</title>
      <link>http://pemako.cn/tools/terminal/</link>
      <pubDate>Thu, 09 Apr 2026 20:00:00 +0800</pubDate>
      <guid>http://pemako.cn/tools/terminal/</guid>
      <description>&lt;h1 id=&#34;go-终端编程原理详解&#34;&gt;Go 终端编程原理详解&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;基于 &lt;code&gt;golang.org/x/term&lt;/code&gt; 和 &lt;code&gt;github.com/creack/pty&lt;/code&gt; 的完整技术文档&lt;/p&gt;&lt;/blockquote&gt;
&lt;hr&gt;
&lt;h2 id=&#34;目录&#34;&gt;目录&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#1-%e7%bb%88%e7%ab%af%e5%9f%ba%e7%a1%80%e6%a6%82%e5%bf%b5&#34;&gt;终端基础概念&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#2-%e6%96%87%e4%bb%b6%e6%8f%8f%e8%bf%b0%e7%ac%a6&#34;&gt;文件描述符&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#3-termios%e7%bb%88%e7%ab%af-io-%e6%8e%a7%e5%88%b6&#34;&gt;termios：终端 I/O 控制&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#4-cooked-%e6%a8%a1%e5%bc%8f-vs-raw-%e6%a8%a1%e5%bc%8f&#34;&gt;Cooked 模式 vs Raw 模式&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#5-golangorgxterm-api-%e8%af%a6%e8%a7%a3&#34;&gt;golang.org/x/term API 详解&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#6-pty%e4%bc%aa%e7%bb%88%e7%ab%af%e5%8e%9f%e7%90%86&#34;&gt;PTY（伪终端）原理&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#7-%e5%ae%8c%e6%95%b4%e7%a4%ba%e4%be%8b%e8%a7%a3%e6%9e%90&#34;&gt;完整示例解析&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#8-%e5%b8%b8%e8%a7%81%e9%97%ae%e9%a2%98%e4%b8%8e%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5&#34;&gt;常见问题与最佳实践&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://pemako.cn/tools/terminal/#9-%e5%8f%82%e8%80%83%e8%b5%84%e6%96%99&#34;&gt;参考资料&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id=&#34;1-终端基础概念&#34;&gt;1. 终端基础概念&lt;/h2&gt;
&lt;h3 id=&#34;什么是终端terminal&#34;&gt;什么是终端（Terminal）&lt;/h3&gt;
&lt;p&gt;终端最初是物理设备（电传打字机、CRT 显示器），通过串口连接到主机，用于输入命令和查看输出。现代操作系统中的&amp;quot;终端&amp;quot;是对这一概念的软件模拟，称为&lt;strong&gt;终端模拟器&lt;/strong&gt;（Terminal Emulator），如 macOS 的 Terminal.app、iTerm2，Linux 上的 GNOME Terminal 等。&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;用户键盘输入
   │
   ▼
┌─────────────┐      ┌──────────────┐      ┌─────────┐
│  终端模拟器   │─────▶│  TTY 驱动层   │─────▶│  进程   │
│ (Terminal)  │◀─────│  (内核)       │◀─────│ (Shell) │
└─────────────┘      └──────────────┘      └─────────┘
   │
   ▼
屏幕显示输出
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;tty-与终端设备文件&#34;&gt;TTY 与终端设备文件&lt;/h3&gt;
&lt;p&gt;在 Linux/macOS 中，终端通过特殊的设备文件暴露给进程：&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
