LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   fork(fork()) is it possible...!!! (https://www.linuxquestions.org/questions/linux-kernel-70/fork-fork-is-it-possible-4175572210/)

Sibasish 02-13-2016 11:11 PM

fork(fork()) is it possible...!!!
 
if it is possible how it works..???

pan64 02-14-2016 02:29 AM

I do not really understand what do you want to achieve. It is possible in general.

ondoho 02-14-2016 10:21 AM

have you tried it?
why shouldn't it work.
Code:

#!/bin/bash

function fork {
        fork
}

fork


rknichols 02-14-2016 11:09 AM

It is posssible, albeit with some complaints from the C compiler since fork() does not take an argument, but what are you trying to accomplish? The process tree you would end up with after fork(fork()) is
Code:

                parent
                  /\
                /  \
                /    \
            child1 child2
                      \
                        \
                      child3



All times are GMT -5. The time now is 05:28 PM.