Re: fork question



David Schwartz wrote:

>
> "Eric" <nospam@xxxxxxxxx> wrote in message
> news:VLednYl3AqJrZU7eRVn-gA@xxxxxxxxxxxxxx
>
>> Well, most of it is that the child reads parent set data, but also, i
>> have a
>> couple of shared ints that can be set by anyone which are used as yes/no
>> flags. once set, they never change but are read (ie checked) fairly often
>> by the reset of the processes.
>
> If they're set before the call to 'fork' and never change, they don't
> need to be shared. There's no problem with the child making its own copy
> during the call to 'fork'.
>
>> Another q.
>> I'm creating the mmap'd are like this (shortened for clarity):
>>
>> Global declarations:
>> void *mptr;
>> typedef struct _TSharedAreaMap {
>> struct info sinfo[MAX_SINFOs];
>> int Flag1;
>> volatile int AbortOps;
>> }TSharedAreaMap;
>> TSharedAreaMap *SharedAreaMap;
>>
>> Mapping function:
>> fd = open(SharedBackingFile, O_RDWR);
>> mptr = mmap(0, Len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
>> SharedAreaMap = (TSharedAreaMap *)mptr;
>>
>> Parent and child both call this but only the parent creates the backing
>> file. Is that corect?
>
> Why should both parent and child call that? Why not just call it
> before
> you 'fork'?
>
> DS
Yup, there's a bug! Thanks, I fixed that and its running much better
Eric

.



Relevant Pages

  • Re: timing a fork
    ... if ($kid) { ... What it does is say that the parent isn't interested in ... Once a parent process has forked it can carry on on its own while the child ... In fact what a call to 'system' does is to fork a child ...
    (perl.beginners)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)