FACT++  1.0
void Parent::fork_em ( )
inline

Definition at line 47 of file dim_fork2.cxx.

References dim_init(), dis_add_service, dis_start_serving, dis_stop_serving, i, and sprintf().

Referenced by main().

47  {
48  //::dis_remove_service(id);
50  ::printf("Sleep a bit to see task disappear in did\n");
51  ::sleep(3);
52  for(size_t i=0; i<sizeof(children)/sizeof(children[0]); ++i) {
53  char nam[132], svc[132];
54  pid_t pid = ::fork();
55  sprintf(nam,"Child_%02ld",i);
56  sprintf(svc,"Child_%02ld/run",i);
57  if ( pid == 0 ) {
58  ::dim_init();
59  ::printf("PID:%d Register Child service Child_%02d/run to DNS....\n",::getpid(),i);
60  id = ::dis_add_service(svc,(char*)"I",&run,sizeof(run),0,0);
62  return;
63  }
64  else if ( pid > 0 ) {
65  //children[i] = new Child(nam, svc);
66  is_parent = true;
67  }
68  else {
69  ::printf("ERROR in fork!!!! %s\n",strerror(errno));
70  ::exit(0);
71  }
72  }
73  ::dim_init();
74  ::sleep(3);
75  ::printf("PID:%d RE-Register Parent to DNS....\n",::getpid());
76  id = ::dis_add_service((char*)"Parent/run",(char*)"I",&run,sizeof(run),0,0);
77  ::dis_start_serving((char*)"Parent");
78  }
int is_parent
Definition: dim_fork2.cxx:24
int i
Definition: db_dim_client.c:21
int run
Definition: dim_fork2.cxx:24
Child * children[50]
Definition: dim_fork2.cxx:25
void dim_init()
Definition: dim_thr.c:111
#define dis_start_serving
Definition: dis.h:8
#define dis_stop_serving
Definition: dis.h:9
#define dis_add_service
Definition: dis.h:12
sprintf(name1,"NewService%d", i)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: