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
なるほど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
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
なるほど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
6.2k
フロントエンドチーム立ち上げで学んだTips / What I learned from organizing the new frontend team
indigolain
0
2.8k
Persisted-queryをやってみた
indigolain
1
1.5k
TEC DEPT 201610 Catal Engineer5期生募集
indigolain
0
500
なるほどUNIXプロセス10~11章
indigolain
0
160
なるほどUNIXプロセス4~5章
indigolain
0
190
Other Decks in Programming
See All in Programming
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.1k
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
270
速習iPhone Duo対応
yuukiw00w
2
930
The Rails Doctrine Decade
koic
2
460
Intent as Code
shoppingjaws
6
1.1k
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
510
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
300
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.3k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
410
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
390
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
4
410
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
410
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Faster Mobile Websites
deanohume
310
32k
Side Projects
sachag
456
43k
Being A Developer After 40
akosma
91
590k
A designer walks into a library…
pauljervisheath
211
25k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
380
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
580
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
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Λ࣮ͬͯݱ͍ͯ͠Δ