fork() question

This is a discussion on fork() question within the C Programming forums, part of the General Programming Boards category; hi, does the child process have access to the parents declared variable?...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    61

    fork() question

    hi, does the child process have access to the parents declared variable?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    Child gets a copy of most things from the parent. If you need to access the actual instance within the parent process, you'll have to use some form of IPC - like shared mem, pipes, ect.. to "communicate" with the parent.

    gg

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, what codeplug is saying is that you get a COPY of all the variables in the original process, but it's not the same variable as in the original process, so changing it won't actually change the original process's content in that variable.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    61
    ic thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A small question about fork( )
    By mlhazan in forum C Programming
    Replies: 4
    Last Post: 08-13-2008, 08:18 PM
  2. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  3. Question sorting character arrays: C programming
    By NeoSigma in forum C Programming
    Replies: 3
    Last Post: 05-23-2003, 09:28 PM
  4. Fork() child process question
    By CrackDown in forum Linux Programming
    Replies: 0
    Last Post: 04-17-2003, 11:58 AM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21