没有合适的资源?快使用搜索试试~ 我知道了~
Working with Unix Processes
需积分: 0 8 下载量 41 浏览量
2016-08-14
12:24:47
上传
评论
收藏 2.08MB PDF 举报
温馨提示
试读
135页
学习理解 Unix Processes
资源推荐
资源详情
资源评论
W o r k i n g w i t h U n i x P r o c e s s e s
C o p y r i g h t © 2 0 1 2 J e s s e S t o r i m e r. A l l r i g h t s r e s e r v e d . T h i s e b o o k i s l i c e n s e d f o r
individual use only.
This is a one-man operation, please respect the time and eort that went into this
book. If you came by a free copy and nd it useful, you can compensate me at
http://workingwithunixprocesses.com.
Ac kn ow le dge m en ts
A big thank you to a few awesome folks who read early drafts of the book, helped me
understand how to market this thing, gave me a push when I needed it, and were all-
around extremely helpful: Sam Storry, Jesse Kaunisviita, and Marc-André Cournoyer.
I have to express my immense gratitude towards my wife and daughter for not only
supporting the erratic schedule that made this book possible, but also always being
there to provide a second opinion. Without your love and support I couldn't have done
this. You make it all worthwhile.
2
C o n t e n t s
9
Introduction
11
Primer
11
Why Care?
12
Harness the Power!
12
Overview
13
S y s t e m C a l l s
14
N o m e n c l a t u r e , w t f ( 2 )
16
Processes: The Atoms of Unix
18
Processes Have IDs
18
Cross Referencing
19
In the Real World
20
S y s t e m C a l l s
21
Processes Have Parents
21
Cross Referencing
22
In the Real World
22
S y s t e m C a l l s
2 3
Processes Have File Descriptors
2 3
E v e r y t h i n g i s a F i l e
2 3
Descriptors Represent Resources
2 7
Standard Streams
28
In the Real World
28
S y s t e m C a l l s
29
Processes Have Resource Limits
29
Fi nd in g t he L im its
30
Soft Limits vs. Hard Limits
31
Bumping the Soft Limit
32
Exceeding the Limit
32
Other Resources
33
In the Real World
34
S y s t e m C a l l s
3 5
Processes Have an Environment
36
I t ' s a h a s h , r i g h t ?
37
In the Real World
37
S y s t e m C a l l s
38
Processes Have Arguments
38
I t ' s a n A r r a y !
39
In the Real World
40
Processes Have Names
40
N a m i n g P r o c e s s e s
42
In the Real World
43
Processes Have Exit Codes
43
H o w t o E x i t a P r o c e s s
4 7
Processes Can Fork
4 7
U s e t h e f o r k ( 2 ) , L u k e
51
M u l t i c o r e P r o g r a m m i n g ?
51
U s i n g a B l o c k
52
In the Real World
52
S y s t e m C a l l s
53
Orphaned Processes
53
Out of Control
54
Abandoned Children
54
Managing Orphans
56
Processes Are Friendly
56
Being CoW Friendly
58
MRI / RBX users
60
Processes Can Wait
61
Babysitting
6 2
Process.wait and Cousins
63
C o m m u n i c a t i n g w i t h P r o c e s s . w a i t 2
65
W a i t i n g f o r S p e c i c C h i l d r e n
66
Race Conditions
68
In the Real World
68
S y s t e m C a l l s
69
Zombie Processes
69
Good Things Come to Those Who wait(2)
71
What Do Zombies Look Like?
71
In The Real World
72
S y s t e m C a l l s
73
Processes Can Get Signals
73
T r a p p i n g S I G C H L D
7 5
SIGCHLD and Concurrency
78
Signals Primer
7 9
Where do Signals Come From?
80
The Big Picture
Download from Wow! eBook <www.wowebook.com>
8 3
R e d e n i n g S i g n a l s
84
Ignori ng Signal s
84
Signal Handlers are Global
85
Being Nice about Redening Signals
87
When Can't You Receive Signals?
87
In the Real World
88
S y s t e m C a l l s
89
Processes Can Communicate
89
Our First Pipe
91
Pipes Are One-Way Only
91
Sharing Pipes
93
Streams vs. Messages
95
R e m o t e I P C ?
95
In the Real World
96
S y s t e m C a l l s
97
D a e m o n P r o c e s s e s
97
The First Process
98
Creating Your First Daemon Process
99
Diving into Rack
100
D a e m o n i z i n g a P r o c e s s , S t e p b y S t e p
101
Process Groups and Session Groups
106
In the Real World
106
S y s t e m C a l l s
107
Spawning Terminal Processes
107
fork + exec
109
Arguments to exec
114
In the Real World
116
S y s t e m C a l l s
117
Ending
117
Abstraction
118
C o m m u n i c a t i o n
118
F a r e w e l l , B u t N o t G o o d b y e
120
App end ix: How Res que Man ages Proces ses
120
The Architecture
121
F o r k i n g f o r M e m o r y M a n a g e m e n t
123
Why Bother?
124
Doesn't the GC clean up for us?
126
App end ix: How Uni co rn Reap s Worker Proce sse s
126
R e a p i n g W h a t ?
132
C o n c l u s i o n
剩余134页未读,继续阅读
资源评论
lifehouse
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功