linux 学习笔记之 Process Control

本文是关于Linux进程控制的学习笔记,重点介绍了fork函数及其采用的copy-on-write技术,以及子进程如何继承父进程的属性。同时,提到了vfork函数,它用于创建新进程并保证子进程先于父进程运行,主要用于exec新程序。此外,还讨论了当父进程在子进程之前终止时,init如何接管孤儿进程。
摘要由CSDN通过智能技术生成
  • Process Identifiers

Every process has unique process ID, a non-negative integer. Process ID 0 is swapper. Process ID 1 is usually the init process and is invoked by the kernel at the end of the bootstrap procedure. The init process never dies. It is a normal user process, not a system process within the kernel, like the swapper, although it does run with super user privileges.

  • Fork Function
    pid_t fork( void )

A technique called copy-on-write (COW) is used. These regions are shared by the parent and child and have their protection changed by the kernel to read-only. If either process tries to modify these regions, the kernel then makes a copy of that piece of memory only, typically a “page” in a virtual memory system.

The parent and child share a file table entry for every open descriptor. It is import that the parent and child share the same of file offset.

  • Child process inherited from parent process:
  1. Real user ID, real group ID, effective user ID, effective group ID
  2. Supplementary group ID
  3. Process group ID
  4. Session ID
  5. Controlling terminal
  6. The set-user-ID and set-group-ID flags
  7. Current working directory
  8. Root directory
  9. File mode creation mask
  10. Signal mask and dispositions
  11. The close-on exec flag from any open file descriptors
  12. Environment
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值