Skip to Content
LINUX系統程式設計 第二版
book

LINUX系統程式設計 第二版

by Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from LINUX系統程式設計 第二版
行程管理
|
181
則會產生一個包含三個行程的行程群組。於是,shell 可以同時通知這三個行程。因為用
戶在控制台(console)之上鍵入這道命令的時候,並未加上結尾的「&」符號,所以我
們也可以說此行程群組位於前景。 5-1 可以看到期程、行程群組、行程與控制終端機
之間的關係。
5-1 期程、行程群組、行程與控制終端機之間的關係
Linux 提供了若干介面,可用於設定與取得「與所指定之行程有關的」期程及行程群
組。這些介面主要是供 shell 所使用,不過也可以用在想要擺脫期程與行程群組之事務
的行程,例如監控程式(daemon)。
期程系統呼叫
shell 會在登入的時候建立新的期程。它們完成此事的方式係透過一個特殊的系統呼叫,
以簡化新期程的建立:
#include <unistd.h>
pid_t setsid (void);
在行程尚不是一個行程群組的帶頭者時,叫用
setsid()
將可建立一個新的期程。進行叫
用之行程,將會成為新期程的帶頭者,以及此期程的唯一成員;此期程並未具有控制終
端機。此呼叫還會在此期程中建立一個新的行程群組,並且讓進行叫用之行程成為行程
群組的帶頭者以及此行程群組的唯一成員。新期程與行程群組之識別碼會被設定成進行
叫用之行程的 pid
期程
行程群組
行程
控制終端機
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

深入理解運算原理|從簡單的機器到無所不能的程式

深入理解運算原理|從簡單的機器到無所不能的程式

Tom Stuart
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow

Publisher Resources

ISBN: 9789862769812