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系統程式設計 第二版
行程管理
|
183
行程群組系統呼叫
setpgid()
會把
pid
所指定之行程的行程群組識別碼設定成
pgid
#define _XOPEN_SOURCE 500
#include <unistd.h>
int setpgid (pid_t pid, pid_t pgid);
如果
pid
引數的值為
0
,則會使用當前的行程。如果
pgid
的值為
0
,則
pid
所指定之行
程的行程識別碼,會被當成行程群組識別碼。
執行成功時,
setpgid()
會傳回
0
。執行成功代表符合以下幾個條件:
pid
所指定之行程必須是進行叫用之行程,或者是進行叫用之行程的一個未調用 exec
的子行程,而且與進行叫用之行程皆隸屬同一個期程。
pid
所指定之行程不可以是一個期程的帶頭行程。
如果
pgid
已經存在,它必須與進行叫用之行程隸屬同一個期程。
pgid
不可以是負值。
發生錯誤時,此呼叫會傳回
-1
,而且會把
errno
設定成下面其中一個錯誤碼:
EACCESS
pid
所指定的行程是進行叫用之行程的一個已經調用 exec 的子行程。
EINVAL
pgid
的值小於
0
EPERM
pid
所指定之行程是一個期程的帶頭行程,或者與進行叫用之行程分屬不同的期程。
亦或者是,企圖把一個行程移往位於不同期程的行程群組。
ESRCH
pid
不是當前行程,
0
,或者不是當前行程的一個子行程。
如同期程,儘管可以取得一個行程的行程群組識別碼,但是用處不大:
#define _XOPEN_SOURCE 500
#include <unistd.h>
pid_t getpgid ...
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

AGILE學習手冊 | SCRUM、XP、精實和看板方法

AGILE學習手冊 | SCRUM、XP、精實和看板方法

Andrew Stellman, Jennifer Greene
管理Kubernetes

管理Kubernetes

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

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

George T.Heineman, Gary Pollice, Stanley Selkow

Publisher Resources

ISBN: 9789862769812