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
67
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
92
あなたの知らないバージョン命名規則
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
SQL文一行も書けない人事がCortexもろもろを使って人事業務を楽にしてみる
ponponmikankan
1
230
クロスボーダーM&AのValue Upを支えるプロダクト開発。日米チームのハブになったプロダクトエンジニアの実践 / Product Engineering Conference 2026
genda
0
120
なぜJMBC(Japan MCP Business Community)? MCPってどう活用できるの?
cdataj
0
110
Snowflakeのコスト最適化を支えるアーキテクチャ設計
ktatsuya
1
1.5k
「図書館」という名前のままでいいのか -Code4Lib JAPANカンファレンス2026 アンカンファレンス報告- / Code4Lib JAPAN Conference 2026: Unconference Report
ykiyota
0
170
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
0
860
NW運用でNWトポロジ可視化ツールに期待すること/shumoku-meetup1
corestate55
2
120
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
480
ペアプロの価値はコードを書くことだけじゃない
codmoninc
PRO
0
210
Multica × 長期記憶:40個のミニプロジェクト管理
eiei114
1
270
リージョンの壁を越える、 ちょっと変わったAWSサービスの話
falken
PRO
1
310
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
260
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
520
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
560
A better future with KSS
kneath
240
18k
エンジニアに許された特別な時間の終わり
watany
108
250k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
480
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Chasing Engaging Ingredients in Design
codingconduct
0
310
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
500
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
390
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
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