由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 问问跟Linux Kernel Programming 有关的问题
相关主题
fork(): why both if and else are executed?Windows XP与Multithreading Programming
does the system guarantee this? (转载)Advanced Linux Programming - Free to download [PDF]
C10M 练习 step 1: 10M sockets问一个简单的问题:fork(), execvp(), 怎么传递函数
为啥用mmap访问文件的效率高呢?请教一个Socket Programming 问题(C language)
fdopen能open同一个fd 两次吗?多线程 编程,process 和 thread 的一些问题。
[转载] Unix/Posix system programming training请教一道题 (转载)
pthread and C++spawn a child process
java & signal process问一个machine learning/SVM 问题
相关话题的讨论汇总
话题: process话题: parent话题: child话题: kernel话题: linux
进入Programming版参与讨论
1 (共1页)
c*********t
发帖数: 2921
1
标 题: 问问跟Linux Kernel 有关的问题
发信站: BBS 未名空间站 (Tue Apr 15 22:49:16 2008)
本人对Linux kernel是菜鸟,有问题请大家指正。
Q1. 关于system call fork()
当parent process用fork()去创建一个child process时,child process得到一个独立
于parent process的地址空间,child process 得到了和parent process完全一样的内
存内容(所有的变量都继承了过来)。从此,child process 和parent process可以独立
的操作自己的变量,互不影响,这对一般的变量来说,很容易理解,毕竟他们在不同的
地址。我的疑问是,如果在fork()前, parent process 有一个file descriptor(对应
于一个打开的文件),在child process被创建后,如果child process close那个file
descriptor,在parent process看来,它的那个file descripto
t****t
发帖数: 6806
2
Q1. This is not about kernel programming; this is "system call". Common Unix
system calls are mostly portable, by conforming to various standards (e.g.
POSIX).
For your specific question: Parent and child process has their separate file
descriptor, but their "open file description", which is system-wide, are
shared. You may think each pair of descriptors are cloned via dup(2). That
means, they have the same file offset, the same I/O attributes. However,
they may be "closed" separately, as I unde

【在 c*********t 的大作中提到】
: 标 题: 问问跟Linux Kernel 有关的问题
: 发信站: BBS 未名空间站 (Tue Apr 15 22:49:16 2008)
: 本人对Linux kernel是菜鸟,有问题请大家指正。
: Q1. 关于system call fork()
: 当parent process用fork()去创建一个child process时,child process得到一个独立
: 于parent process的地址空间,child process 得到了和parent process完全一样的内
: 存内容(所有的变量都继承了过来)。从此,child process 和parent process可以独立
: 的操作自己的变量,互不影响,这对一般的变量来说,很容易理解,毕竟他们在不同的
: 地址。我的疑问是,如果在fork()前, parent process 有一个file descriptor(对应
: 于一个打开的文件),在child process被创建后,如果child process close那个file

1 (共1页)
进入Programming版参与讨论
相关主题
问一个machine learning/SVM 问题fdopen能open同一个fd 两次吗?
C++ delete[转载] Unix/Posix system programming training
请教一道练习题(C,OS)pthread and C++
问个c++ 编译的问题java & signal process
fork(): why both if and else are executed?Windows XP与Multithreading Programming
does the system guarantee this? (转载)Advanced Linux Programming - Free to download [PDF]
C10M 练习 step 1: 10M sockets问一个简单的问题:fork(), execvp(), 怎么传递函数
为啥用mmap访问文件的效率高呢?请教一个Socket Programming 问题(C language)
相关话题的讨论汇总
话题: process话题: parent话题: child话题: kernel话题: linux