Re: what will connect the fork() with its following code ? a simple example below:

2005-09-07 Thread Bernd Petrovitsch
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{ > >

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-07 Thread Bernd Petrovitsch
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{ .

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread Valdis . Kletnieks
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.,

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread Dirk Gerdes
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 -

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread linux-os \(Dick Johnson\)
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

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread Sat.
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

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread Bernd Petrovitsch
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

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread Bernd Petrovitsch
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

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread Sat.
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

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread linux-os \(Dick Johnson\)
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

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread Dirk Gerdes
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 -

Re: what will connect the fork() with its following code ? a simple example below:

2005-09-06 Thread Valdis . Kletnieks
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