1.0x80号中断所引发的中断会使程序的执行陷入内核,程序执行内核代码。
2.文件表的概念:文件表存在于进程描述符pcd中。系统调用open每打开一个文件都会在文件表中添加一项。open的返回值是该文件在文件表中的下标。在文件表中0号下标对应的stdin(键盘输入)的文件,所以也可以直接使用0来代替stdin。
3.使用fork完成的是对文件描述符的复制。
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<assert.h>
#include<fcntl.h>
int main()
{
int fd=open("./file",O_RDONLY);
assert(fd!=-1);
pid_t pid=fork();
assert(pid!=-1);
if(pid==0)
{
char buff[8]={0};
read(fd,buff,1);
printf("child:%s\n",buff);
sleep(1);
read(fd,buff,1);
printf("child:%s\n",buff);
}
}