Find the answer to your Linux question:
Results 1 to 1 of 1

Thread: A "clone" doubt

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Angry A "clone" doubt

    int fn(void *a)
            int *p;
            printf("Value of a is = %d",*p);
            return 0;
    int main()
            int *i,a=125;
            pid_t child;
            printf("\n This is parent with id : %d",getppid());
            printf("\n Got the child id as : %d",child);
            return 0;
    In the above program, In function "fun()" the first printf statement (i.e, printing the value of a) is not printing anything in the screen. If i give the second printf(simply a new line) i'm getting the output.

    1. can anyone explain me why?

    2. My friends are telling that I should not use "printf", if I create a process by using "clone()". They are telling me to use "write()" instead.
    If they are telling the correct answer, also explain me why I should not use printf in clone?
    Last edited by MikeTbob; 10-02-2011 at 03:43 PM. Reason: Added Code Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts