[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: programming: fork() related question
- To: misc_(_at_)_openbsd_(_dot_)_org
- Subject: Re: programming: fork() related question
- From: "dreamwvr_(_at_)_dreamwvr_(_dot_)_com" <dreamwvr_(_at_)_dreamwvr_(_dot_)_com>
- Date: Sat, 13 Dec 2003 13:20:18 -0700
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 \? ;-]
Visit your host, monkey.org