Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
LINUX系統程式設計 第二版
by
Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from
LINUX系統程式設計 第二版
364
|
第十章
#include <unistd.h>
int pause (void);
pause()
只會在接收到被捕捉的信號時才會返回,此狀況下,信號會被處理,而且
pause()
會傳回
-1
並且把
errno
設定為
EINTR
。如果核心引發了一個被忽略的信號,則行
程不會被喚醒。
在
Linux
核心中,
pause()
是最簡單的系統呼叫之一。它只會完成兩項工作。首先,它會
讓行程進入可中斷的休眠狀態。其次,它會呼叫
schedule()
,以便調用
Linux
的行程排
班器,找出另一個行程來運行。因為此行程實際上並未在等待什麼,所以核心將不會喚
醒它,除非它收到一個信號。這整個過程只需要用到兩列
C
程式碼。
2
範例
讓我們來看兩個簡單的例子。第一個例子替
SIGINT
註冊了一個信號處理程序(只會印出
一段訊息),然後終止程式(因為
SIGINT
總是會這麼做):
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
/* SIGINT
的處理程序
*/
static void sigint_handler (int signo)
{
/*
*
技術上,你不應該在單一處理程序中
*
使用
printf()
,但它不是世界末日。
*
我將在第
10
章〈可再進入性〉一節說明為什麼。
*/
printf ("Caught SIGINT!\n");
exit (EXIT_SUCCESS);
}
int main (void) ...
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.
Start your free trial
You might also like
優雅的SciPy|Python科學研究的美學
Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
成為卓越程式設計師的38項必修法則
Pete Goodliffe
深入理解運算原理|從簡單的機器到無所不能的程式
Tom Stuart
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9789862769812