-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessctl.html
145 lines (136 loc) · 6.38 KB
/
processctl.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<title>进程控制 | 《UNIX环境高级编程》学习笔记</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<meta content="" name="description"/>
<meta content="GitBook 2.6.7" name="generator"/>
<meta content="true" name="HandheldFriendly"/>
<meta content="width=device-width, initial-scale=1, user-scalable=no" name="viewport"/>
<meta content="yes" name="apple-mobile-web-app-capable"/>
<meta content="black" name="apple-mobile-web-app-status-bar-style"/>
<link href="gitbook/images/apple-touch-icon-precomposed-152.png" rel="apple-touch-icon-precomposed" sizes="152x152"/>
<link href="gitbook/images/favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link href="gitbook/style.css" rel="stylesheet"/>
<link href="gitbook/plugins/gitbook-plugin-highlight/website.css" rel="stylesheet"/>
<link href="gitbook/plugins/gitbook-plugin-search/search.css" rel="stylesheet"/>
<link href="gitbook/plugins/gitbook-plugin-fontsettings/website.css" rel="stylesheet"/>
<link href="./processenv.html" rel="prev"/>
</head>
<body>
<div class="book" data-basepath="." data-chapter-title="进程控制" data-filepath="processctl.md" data-innerlanguage="" data-level="8" data-revision="Thu May 17 2018 00:06:37 GMT+0800 (CST)">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="0" data-path="index.html">
<a href="./index.html">
<i class="fa fa-check"></i>
Introduction
</a>
</li>
<li class="chapter " data-level="1" data-path="unixbase.html">
<a href="./unixbase.html">
<i class="fa fa-check"></i>
<b>1.</b>
UNIX 基础
</a>
</li>
<li class="chapter " data-level="2" data-path="unixstandard.html">
<a href="./unixstandard.html">
<i class="fa fa-check"></i>
<b>2.</b>
UNIX标准及其实现
</a>
</li>
<li class="chapter " data-level="3" data-path="fileio.html">
<a href="./fileio.html">
<i class="fa fa-check"></i>
<b>3.</b>
文件IO
</a>
</li>
<li class="chapter " data-level="4" data-path="filestat.html">
<a href="./filestat.html">
<i class="fa fa-check"></i>
<b>4.</b>
文件属性
</a>
</li>
<li class="chapter " data-level="5" data-path="libio.html">
<a href="./libio.html">
<i class="fa fa-check"></i>
<b>5.</b>
标准IO库
</a>
</li>
<li class="chapter " data-level="6" data-path="sysinfo.html">
<a href="./sysinfo.html">
<i class="fa fa-check"></i>
<b>6.</b>
系统文件和信息
</a>
</li>
<li class="chapter " data-level="7" data-path="processenv.html">
<a href="./processenv.html">
<i class="fa fa-check"></i>
<b>7.</b>
进程环境
</a>
</li>
<li class="chapter active" data-level="8" data-path="processctl.html">
<a href="./processctl.html">
<i class="fa fa-check"></i>
<b>8.</b>
进程控制
</a>
</li>
<li class="divider"></li>
<li>
<a class="homepage-back" href="https://freebug.top/book/" target="_self">
Back to Book</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Actions Left -->
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="./">《UNIX环境高级编程》学习笔记</a>
</h1>
</div>
<div class="page-wrapper" role="main" tabindex="-1">
<div class="page-inner">
<section class="normal" id="section-">
<h1 id="进程控制">进程控制</h1>
<hr/>
<p>进程控制包括创建新进程,执行进程和终止进程。</p>
<h4 id="进程标识">进程标识</h4>
<p>每个进程都有一个非负数表示的唯一进程ID,因为进程ID具有唯一性,因此常常把它作为其它标识符的一部分,虽然是唯一的,但是进程ID是可复用的,当一个进程结束后,其进程ID就成为复用的候选者,大多数UNIX实现延迟复用算法。这样可以避免把新进程搞成已经被终止掉的进程,系统具有一些专用进程,ID为0的是调度进程,也叫做交换进程,这个进程是内核的一部分,它并不执行任何程序,也叫做系统进程,进程ID为1的是init进程,在自举过程结束的时候由内核调用,这个进程负责在自举内核以后启动一个UNIX系统,init通常读取与系统有关的初始化文件,并将系统引导到一个状态,init进程绝不会终止,它是一个普通的用户进程,但是以超级用户特权来运行,它也是所有孤儿进程的父进程。每个UNIX系统还提供了一套操作系统服务的内核进程,例如在某些UNIX系统的虚拟存储器实现中,进程ID2是页守护进程,此进程负责支持虚拟存储器系统的分页操作。</p>
<h4 id="函数fork">函数fork</h4>
<p>fork创建一个子进程,fork函数调用一次返回两次,子进程的返回值是0,父进程的返回值是子进程的进程ID,注意一个子进程的ID不可能是0,子进程和父进程继续执行fork调用之后的指令,子进程是父进程的副本</p>
</section>
</div>
</div>
</div>
<a aria-label="Previous page: 进程环境" class="navigation navigation-prev navigation-unique" href="./processenv.html"><i class="fa fa-angle-left"></i></a>
</div>
</div>
<script src="gitbook/app.js"></script>
<script src="gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
<script src="gitbook/plugins/gitbook-plugin-search/search.js"></script>
<script src="gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
<script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
<script>
require(["gitbook"], function(gitbook) {
var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
gitbook.start(config);
});
</script>
</body>
</html>