Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
なるほどUNIXプロセス14_15章
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
indigolain
May 07, 2016
Programming
180
0
Share
なるほどUNIXプロセス14_15章
なるほどUNIXプロセス14_15章
http://tatsu-zine.com/books/naruhounix
indigolain
May 07, 2016
More Decks by indigolain
See All by indigolain
スタディサプリにおける TypeScript 活用事例と今後の展望 / jsconf-jp-2021
indigolain
3
6k
フロントエンドチーム立ち上げで学んだTips / What I learned from organizing the new frontend team
indigolain
0
2.7k
Persisted-queryをやってみた
indigolain
1
1.4k
TEC DEPT 201610 Catal Engineer5期生募集
indigolain
0
490
なるほどUNIXプロセス10~11章
indigolain
0
160
なるほどUNIXプロセス4~5章
indigolain
0
180
Other Decks in Programming
See All in Programming
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.5k
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
650
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
270
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
590
AI Assistants for YourAngular Solutions @Angular Graz, March 2026
manfredsteyer
PRO
0
140
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
130
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
150
「速くなった気がする」をデータで疑う
senleaf24
0
130
Rethinking API Platform Filters
vinceamstoutz
0
5.1k
RSAが破られる前に知っておきたい 耐量子計算機暗号(PQC)入門 / Intro to PQC: Preparing for the Post-RSA Era
mackey0225
3
110
Geminiをパートナーに神社DXシステムを個人開発した話(いなめぐDX 開発振り返り)
fujiba
0
130
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
140
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
510
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
210
Faster Mobile Websites
deanohume
310
31k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
99
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
320
RailsConf 2023
tenderlove
30
1.4k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
99
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
880
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
290
Prompt Engineering for Job Search
mfonobong
0
240
Transcript
14~15ষ ͳΔ΄ͲUNIXϓϩηε
ςΩετ ୈ̍̐ষϓϩηεͯΔ ▸ ࢠकΓ ▸ Process.waitͱͦͷҰ ▸ Process.wait2ΛͬͯΓͱΓ͢Δ ▸ ಛఆͷࢠϓϩηεΛͭ
▸ ڝ߹ঢ়ଶ ▸ ࣮༻ྫ ▸ ͜ͷষͰѻͬͨγεςϜίʔϧ
ςΩετ ࢠकΓ ▸ ͜Ε·Ͱѻ͖ͬͯͨfork(2)ͷྫʮܸͪͬͺͳ͠(fire and forget)ʯ ▸ ࢠϓϩηεଆͰ͋ΔॲཧΛͤͭͭ͞ɺඇಉظͰϓϩηε ͰผͷॲཧΛ͢Δ߹ʹྑ͍ ▸
͜ͷ߹Ҏ֎ࢠϓϩηεΛཧͯ͘͠ΕΔΈ͕ඞཁ ▸ ͜Ε͕Process.wait
ςΩετ ࢠकΓ ▸ process_wait_example.rb ▸ Process.waitࢠϓϩηεͷͲΕ͔͕̍ͭऴྃ͢Δ·Ͱͷ ؒɺϓϩηεΛϒϩοΫͯͭ͠ɻ
ςΩετ PROCESS.WAITͱͦͷҰ ▸ ̍ͭҎ্ͷϓϩηεΛࢹ͢Δඞཁ͕͋Δ߹ɺͲͷࢠϓϩ ηε͕ऴ͔ྃͨ͠ΛΔඞཁ͕͋Δ ▸ Process.waitͷΓऴྃͨ͠ࢠϓϩηεͷpidΛฦ͢ͷ Ͱɺ͜ΕΛ͏ ▸ process_wait_pid_example.rb
ςΩετ PROCESS.WAIT2ΛͬͯΓͱΓ͢Δ ▸ Process.waitʹProcess.wait2ͱ͍͏ੰ͕͋Δ ▸ Process.wait2pidͱऴྃεςʔλεΛฦΓͱͯ͠ฦ͢ ▸ ऴྃεςʔλεऴྃίʔυʹΑΔϓϩηεಉ࢜ͷ௨৴खஈͱ͠ ͯΘΕΔ ▸
Process.wait2͕ฦ͢ऴྃεςʔλεProcess::StatusΫϥεͷΠ ϯελϯε ▸ process_wait2_example.rb
ςΩετ ಛఆͷࢠϓϩηεΛͭ ▸ Process.watpidͱProcess.waitpid2 ▸ ऴྃΛͭͷҙͷࢠϓϩηεͰͳ͘ɺࢦఆͨ͠ࢠϓϩηε ▸ ऴྃΛͭࢠϓϩηεpidͰࢦఆ͢Δ ▸ ݩಉؔ͡Λࢦ͍ͯ͠Δ
▸ Process.waitʹpidΛ͢ ▸ Process.waitpidʹ-1Λ͢
ςΩετ ڝ߹ঢ়ଶ ▸ Χʔωϧऴྃͨ͠ϓϩηεΛΩϡʔʹೖΕΔ ▸ ऴྃΛͭࢠϓϩηε͕1ͭແ͍ঢ়ଶͰProcess.waitΛݺ ͼग़͢ͱErrno::ECHILDྫ֎͕ૹग़͞ΕΔ ▸ no_processwait.rb
ςΩετ ࣮༻ྫ ▸ ࢠϓϩηεΛ׆༻͢Δύλʔϯ ▸ ༻ҙͨ͠1ͭͷϓϩηε͔ΒฒߦॲཧͷͨΊʹෳͷࢠϓϩηεΛੜ ͯ͠ɺͦͷޙࢠϓϩηεͷ໘ΛΈΔͱ͍͏ܗࣜ ▸ Ԡ/ऴྃ࣌ͷޙ࢝ͳͲ ▸
Unicorn͕͜ͷύλʔϯΛ࠾༻͍ͯ͠Δ ▸ αʔόىಈ࣌ʹϫʔΧʔϓϩηεΛ͍ͭ͘͏͔Λࢦఆ͢Δ ▸ Unicornʹؔͯ͠2ʮUnicornͷϫʔΧʔϓϩηεͷཧʯࢀর
ςΩετ ͜ͷষͰѻͬͨγεςϜίʔϧ ▸ Process.waitܥwaitpid(2)ʹରԠ͍ͯ͠Δ
ςΩετ ୈ̍̑ষκϯϏϓϩηε ▸ Ռใ৸ͯͯ ▸ κϯϏͲΜͳ෩ʹΈ͑Δͷ͔ʁ ▸ ࣮༻ྫ ▸ ͜ͷষͰѻͬͨγεςϜίʔϧ
ςΩετ Ռใ৸ͯͯ ▸ Χʔωϧϓϩηε͕Process.waitΛͬͯͦͷใΛཁٻ͢Δ·Ͱ ऴྃͨ͠ࢠϓϩηεͷใΛͣͬͱ࣋ͪଓ͚Δ ▸ ΧʔωϧͷϦιʔεͷແବ͍ʹͭͳ͕ͬͯ͠·͏ ▸ Process.waitΛͬͯࢠϓϩηεͷऴྃΛͨͳ͍߹ɺࢠϓϩηεΛ σλονͤͶͳΒͳ͍
▸ Process.detachpidͰࢦఆ͞ΕͨࢠϓϩηεͷऴྃΛͭεϨουΛ ੜ͢Δ ▸ detach_example.rb
ςΩετ κϯϏͱͲͷΑ͏ʹݟ͑Δͷ͔ʁ ▸ zombie_process_example.rb ▸ ps -ho pid, state -p
[κϯϏʹͳͬͨϓϩηεͷpid]
ςΩετ ࣮༻ྫ ▸ ϓϩηεʹͨΕͣʹࢮΜͰ͠·ͬͨࢠϓϩηεྫ֎ͳ͘κϯϏϓ ϩηεʹͳΔ ▸ ϓϩηε͕κϯϏϓϩηεͷऴྃεςʔλεΛऔಘ͢Εɺใ ফ͑Δ ▸ ॲཧΛόοΫάϥϯυͰ࣮ߦ͢Δඞཁ͕͋ΔόΠΠʹɺઐ༻ͷόο
ΫάϥϯυΩϡʔΠϯάγεςϜ͕ΘΕΔ͜ͱ͕ଟ͍ ▸ spawnlingͱ͍͏gemΛ͑ɺϓϩηεεϨουΛѻ͏૯শతͳ APIΛఏڙ͢Δ͜ͱʹՃ͑ͯɺʮܸͪͬ์͠ʯͰੜͨ͠ࢠϓϩηεΛ Ͱλονͯ͘͠ΕΔ
ςΩετ ͜ͷষͰѻͬͨγεςϜίʔϧ ▸ Process.detachʹ͋ͨΔγεςϜίʔϧଘࡏ͠ͳ͍ ▸ RubyͰεϨουͱProcess.waitΛ࣮ͬͯݱ͍ͯ͠Δ