On Tue, 2005-09-06 at 12:58 -0400, [EMAIL PROTECTED] wrote:
> On Tue, 06 Sep 2005 17:15:51 +0800, "Sat." said:
>
> Not a kernel problem, please consult an intro-to-C list next time
>
> > if(!(pid=fork())){
> > ..
> > printk("in child process");
> > ..
> > }else{
> >
On Tue, 2005-09-06 at 12:58 -0400, [EMAIL PROTECTED] wrote:
On Tue, 06 Sep 2005 17:15:51 +0800, Sat. said:
Not a kernel problem, please consult an intro-to-C list next time
if(!(pid=fork())){
..
printk(in child process);
..
}else{
.
On Tue, 06 Sep 2005 17:15:51 +0800, "Sat." said:
Not a kernel problem, please consult an intro-to-C list next time
> if(!(pid=fork())){
> ..
> printk("in child process");
> ..
> }else{
> .
> printk("in father process");
> .
> }
>
> values.,
fork returns 0 to the child and the pid of the child to the parent.
both child and parent get the same code, so the child gets true in the
if-statement and the parent gets false.
it would be the same as
pid = fork();
if (pid == 0){
// child
}
else{
// parent
}
- Original Message -
On Tue, 6 Sep 2005, Sat. wrote:
> here is a snip in 0.11 version linux ,
> in linux/init/main.c
>
>
> 179 if (!(pid=fork())) {
> 180 close(0);
> 181 if (open( "/etc/rc",O_RDONLY,0))
> 182 _exit(1);
> 183 execve( "/bin/sh",argv_rc,envp_rc);
> 184 _exit(2);
> 185 }
>
> natually, the code from 180
here is a snip in 0.11 version linux ,
in linux/init/main.c
179 if (!(pid=fork())) {
180 close(0);
181 if (open( "/etc/rc",O_RDONLY,0))
182 _exit(1);
183 execve( "/bin/sh",argv_rc,envp_rc);
184 _exit(2);
185 }
natually, the code from 180 to 184 is runned by the new process, what
I can
On Tue, 2005-09-06 at 17:15 +0800, Sat. wrote:
> if(!(pid=fork())){
> ..
> printk("in child process");
> ..
> }else{
> .
> printk("in father process");
> .
> }
>
> this is a classical example, when the fork() system call runs, it will
> build a new
On Tue, 2005-09-06 at 17:15 +0800, Sat. wrote:
if(!(pid=fork())){
..
printk(in child process);
..
}else{
.
printk(in father process);
.
}
this is a classical example, when the fork() system call runs, it will
build a new process and
here is a snip in 0.11 version linux ,
in linux/init/main.c
179 if (!(pid=fork())) {
180 close(0);
181 if (open( /etc/rc,O_RDONLY,0))
182 _exit(1);
183 execve( /bin/sh,argv_rc,envp_rc);
184 _exit(2);
185 }
natually, the code from 180 to 184 is runned by the new process, what
I can understand
On Tue, 6 Sep 2005, Sat. wrote:
here is a snip in 0.11 version linux ,
in linux/init/main.c
179 if (!(pid=fork())) {
180 close(0);
181 if (open( /etc/rc,O_RDONLY,0))
182 _exit(1);
183 execve( /bin/sh,argv_rc,envp_rc);
184 _exit(2);
185 }
natually, the code from 180 to 184 is runned
fork returns 0 to the child and the pid of the child to the parent.
both child and parent get the same code, so the child gets true in the
if-statement and the parent gets false.
it would be the same as
pid = fork();
if (pid == 0){
// child
}
else{
// parent
}
- Original Message -
On Tue, 06 Sep 2005 17:15:51 +0800, Sat. said:
Not a kernel problem, please consult an intro-to-C list next time
if(!(pid=fork())){
..
printk(in child process);
..
}else{
.
printk(in father process);
.
}
values., and do nothing . so
12 matches
Mail list logo