-1

I want to fork a sub-program to do some routine jobs or listen to some sockets.
If this can be done, please show with a simple example how this forked program can access the G-WAN KV store via a persistent pointer.

PhonicUK
  • 13,486
  • 4
  • 43
  • 62
k.k. lou
  • 1,805
  • 2
  • 13
  • 16

1 Answers1

0

I guess you want to execute a third-party program rather than forking G-WAN.

If you fork() G-WAN, you will have a second process that fails to listen to the host definitions already used by the first instance of G-WAN to listen on IPs and port numbers.

Starting from there, you should rather use the maintenance script or launch a third-party program (which will not share the memory address space of G-WAN).

Now, you can't share in-memory KV stores between processes yet - but this is on our TODO list.

Gil
  • 3,279
  • 1
  • 15
  • 25
  • what if, in main.c, i use pthread to execute a function (ansi c script including gwan.h), can this function access the KV store? – k.k. lou Nov 04 '12 at 14:52
  • 2
    Yes, this would work (either with a handler or a servlet); pass the kv_store pointer to the thread. Note that such a thread could also listen on free port numbers. You can create as many thread you wish but it would be wise to create the one(s) you need at startup with a static variable like: firsttime = 1; if(firsttime) { firsttime = 0; phread_create(); } – Gil Nov 05 '12 at 06:10