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 23, 2025
Technology
92
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
シェルのジョブ
以下動画のテキストです。
https://youtu.be/LvuQqQvtork
Satoru Takeuchi
PRO
February 23, 2025
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
119-多機能ファイルシステムBtrfs_のコピー.pdf
sat
PRO
1
68
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
93
あなたの知らないバージョン命名規則
sat
PRO
3
900
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
64
Machine Check Exception
sat
PRO
2
66
バイナリダンプの模様を読む
sat
PRO
0
89
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
87
114-ファイルのshallow_copy.pdf
sat
PRO
2
57
113-Btrfsのスナップショット.pdf
sat
PRO
0
40
Other Decks in Technology
See All in Technology
作品が生態系になった ─ Mini Tokyo 3D から世界へ
nagix
0
190
LLMに渡さなかった仕事
nanaism
0
170
30座EKS, 180次升級淬煉的EKS Upgrade Skill 的歷程
eric8230
0
160
20260912_スクラムにジェネラリストは必要か
ryugen04
0
420
AIによるクリエイティブ生成を行う上での試行錯誤
plaidtech
PRO
0
140
アプリをもっと"iOSアプリっぽく"する小さな工夫 / Small Touches That Make Your App Feel More Like an iOS App
matsuji
1
890
range over func 2年間の軌跡 Issue #56413 はGoのエコシステムをどう変えたか
ryujicre8ive
0
190
【技術的負債conf】事業成長に伴う技術的負債の説明責任とAIによるモニタリング、認知的負債について
i35_267
2
1.6k
GoにおけるFFIのこれまでとこれから
goccy
5
3.3k
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
1
1.3k
beyond jj: config & tools ecosystem
indirect
0
410
登壇の自信を奪う3匹のオバケ / 3 Ghosts That Rob You of Your Confidence in Public Speaking
pauli
8
920
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.5k
Facilitating Awesome Meetings
lara
57
7.1k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
How STYLIGHT went responsive
nonsquared
100
6.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
910
Fireside Chat
paigeccino
43
4k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
670
Design in an AI World
tapps
1
320
Building AI with AI
inesmontani
PRO
1
1.2k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
520
Transcript
シェルのジョブ Feb. 23rd, 2025 Satoru Takeuchi X: satoru_takeuchi 1
シェルのジョブ • シェル上での1つのコマンド、またはパイプで繋がれた一連のプロセス • 2種類ある ◦ フォアグラウンドジョブ : 実行時に末尾に”&”を付けない(e.g. ps
ajx | less) ▪ 端末に直接アクセスできる ▪ セッションの中で常に 1つ ◦ バックグラウンドジョブ : 実行時に末尾に”&”を付ける(e.g. go build &) ▪ バックグラウンド(裏側)で実行 ▪ 端末に直接アクセスできない • アクセスするとフォアグラウンドプロセスになるまで待たされる ▪ セッションの中で複数存在できる 2
プロセスグループ 3 • カーネルの機能 • シェルのセッションはプロセスグループを使って実装している ◦ フォアグラウンドジョブ => フォアグラウンドプロセスグループ
◦ バックグラウンドジョブ => バックグラウンドプロセスグループ • パイプラインの最初のプロセスをプロセスグループリーダーと呼ぶ ◦ プロセスグループリーダーは端末の入出力を直接受け取る • プロセスグループごとに固有のID、プロセスグループIDが対応する ◦ プロセスグループIDはプロセスグループリーダーの PIDと等しい
セッションとジョブの関係 4 セッション プロセスグループ(ジョブ)1 (バックグラウンド) プロセスグループ(ジョブ)2 (フォアグラウンド) ps aux less
端末 go build bash 生成 生成&パイプでつなげる アクセス可 フォアグラウンド になるまで アクセスを待たさ れる
例 • “go build”はバックグラウンドジョブ(プロセスグループ)として実行 • “ps aux | less”はフォアグラウンドジョブ(プロセスグループ)として実行 5
$ go build & $ ps ajx | less PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND ... 19261 19262 19262 19262 pts/0 19653 Ss 1000 0:00 -bash ... 19262 19653 19653 19262 pts/0 19653 R+ 1000 0:00 ps ajx 19262 19654 19653 19262 pts/0 19653 S+ 1000 0:00 less ...
プロセスグループとシグナル • シグナルはプロセスグループに送れる ◦ プロセスグループ内の全プロセスにシグナルを送る ◦ “kill”コマンドの場合、例えば ”kill -100”を実行するとプロセスグループ (IDは100)にシグナルを送る
• 疑似端末上で”C-c”を押すとフォアグラウンドプロセスグループにSIGINTシグナル を送る ◦ バックグラウンドプロセスグループには送らないのでバックグラウンドプロセスは残る 6
まとめ • シェルのセッションにはジョブという概念がある • ジョブはカーネルのプロセスグループという機能によって実現している ◦ フォアグラウンドジョブ => フォアグラウンドプロセスグループ ▪
端末に直接アクセスできる ◦ バックグラウンドジョブ => バックグラウンドプロセスグループ ▪ 端末にアクセスすると待たされる • プロセスグループにシグナルを送信すると、所属する全プロセスにシグナルを送信 する 7