Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
シェルのセッション
Search
Satoru Takeuchi
PRO
February 08, 2025
Technology
120
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
シェルのセッション
以下動画のテキストです。
https://youtu.be/obf6qnCBkQU
Satoru Takeuchi
PRO
February 08, 2025
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
119-多機能ファイルシステムBtrfs_のコピー.pdf
sat
PRO
1
74
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
100
あなたの知らないバージョン命名規則
sat
PRO
3
920
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
67
Machine Check Exception
sat
PRO
2
68
バイナリダンプの模様を読む
sat
PRO
0
110
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
100
114-ファイルのshallow_copy.pdf
sat
PRO
2
59
113-Btrfsのスナップショット.pdf
sat
PRO
0
42
Other Decks in Technology
See All in Technology
IoTデバイスを繋げるプロトコルMatterをAndroidで使用する方法
harutiro
0
110
全社共通データ基盤をつくる。ソニーのDatabricks活用とデータガバナンス設計の裏側
sony
0
330
spanner-autoscalerに学ぶ CRD設計パターン 〜自動化と緊急時対応を両立する Kubernetesコントローラーの作り方〜
tkuchiki
0
230
More Freedom on the Same Shared GPU Cluster: A Small Team’s Experience with vCluster
nttcom
0
120
生成AIと進める探索的データ分析(2026.10.03 第122回Tokyo.R勉強会)
tatamiya
2
1.3k
20260930_Gemma4_Hands-on
tsho
0
210
組み立てて楽しむ AWS Blocks 入門
kmiya84377
0
190
企業の現実世界をグラフで写し取る
sansantech
PRO
0
250
Codex概要
ymiya55
0
260
「とりあえず動く」の先へ。 AI時代のチーム開発と内部設計/2026-slsdays
slsops
0
130
Incremental HTTP
kazuho
5
2k
サーバーフルコンピューティング?AWS Lambda
iwatatomoya
1
200
Featured
See All Featured
Designing for Timeless Needs
cassininazir
1
520
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
300
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Embracing the Ebb and Flow
colly
88
5.2k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
900
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
730
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
Transcript
シェルのセッション Feb. 8th, 2025 Satoru Takeuchi X: satoru_takeuchi 1
シェルのセッション • ログインしてシェルが立ち上がってからログアウトしてシェルが終了するまでの期間 • ログインセッションとも呼ばれる • カーネルのセッション機能を使っている 2
カーネルのセッション機能 • 各セッションにはセッションID(SID)が割り当てられる • セッションを開始したプロセス(bashなど)がセッションリーダーとなる • 端末(デバイス名はttyXやptyX)に結びついている ◦ 📝 その33「端末デバイス」
◦ ほとんどの場合はgtermのような疑似端末に結びついている ◦ よくわからなければ「文字だらけの白黒のウィンドウ」くらいの感覚でよいです • ログインセッションでないセッションもある ◦ 📝 別動画で紹介予定 3
セッションIDの表示 • bashからps ajxを実行 4 $ ps ajx PPID PID
PGID SID TTY TPGID STAT UID TIME COMMAND ... 19261 19262 19262 19262 pts/0 19647 Ss 1000 0:00 -bash ... 19262 19647 19647 19262 pts/0 19647 R+ 1000 0:00 ps ajx ...
システムに複数のログインセッションが存在する場合 5 Aさんのセッション: go build & vim Bさんのセッション1: ps aux
| less Bさんのセッション2: sleep 10 bash go build zsh ps aux less vim zsh sleep 10 セッション 端末 pty/0 pty/1 pty/2
セッションに紐付く端末が末の接続が切れると… • カーネルがセッションリーダー(bashなど)にSIGHUPを送る • bashはSIGHUPのハンドラで同じセッションに属する全ジョブにSIGHUPを送って から終了 ◦ ジョブはパイプで繋がれた一連のプロセス ▪ 📝
別動画で解説予定 ◦ ジョブにSIGHUPを送る ~= プロセスにSIGHUPを送る ◦ プロセスはSIGHUPを受信するとデフォルトで終了する • 疑似端末ウィンドウを閉じると端末から実行したプロセスが全部終了するのはこの 仕組みによるもの 6
プロセスを終了させたくなければ… • プログラムでの対処 ◦ SIGHUPを無視するコードを書く ◦ SIGHUPのシグナルハンドラを設定して、このシグナルを受信しても終了しないようにする • 便利コマンド ◦
nohupコマンド ▪ SIGHUPを無視する設定にしたうえでプログラムを起動する ◦ bashのdisown組み込みコマンド ▪ ジョブ(プロセスのかたまり)をbashの管理下から外す ▪ bashがSIGHUPを受け取ってもdisownしたジョブにはSIGHUPを送らない 7
まとめ • ログインしてからシェルが立ち上がってログアウトしてシェルが終了するまでに保持 される期間をセッションと呼ぶ • カーネルのセッション機能に結びついている • セッションは端末に結びついている ◦ 端末の接続が切れると通常はセッションに紐づくプロセスはすべて終了する
◦ nohupコマンドやbashのdisown組み込みコマンドを使うと終了を避けられる 8