[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programming: fork() related question



On Sat, Dec 13, 2003 at 08:47:52PM +0100, Alexander Farber wrote:
> On Sat, Dec 13, 2003 at 10:03:30PM +0300, Alexander Yurchenko wrote:
> > On Sat, Dec 13, 2003 at 07:53:37PM +0100, Sacha Ligthert wrote:
> > > Is there a way to have the same values in the parent and a child of a 
> > > fork().
> > > 
> > > For example:
> > > int   a;
> > > a=0;
> > > if (!fork())
> > > { /*Child*/ } else { /*Parent*/ }
> > > 
> > > If I where to edit value "a" in the parent, how could I get the same 
> > > value of "a" in the child?
> > > 
> > Shared memory?
> > shmat(2)
> 
> Or a pipe(2)
yes that would do it. Another way to consider is..
socketpair();
I am pretty sure Steven's has a book dedicated on things IPC.

Best Regards,
dreamwvr_(_at_)_dreamwvr_(_dot_)_com

-- 
/*  Security is a work in progress - dreamwvr                 */
#                               48 69 65 72 6F 70 68 61 6E 74 32
# Note: To begin Journey type man afterboot,man help,man hier[.]      
# 66 6F 72 20 48 69 72 65                              0000 0001
// "Who's Afraid of Schrodinger's Cat?" /var/(.)?mail/me \?  ;-]