Beispiel #1
0
void add_fork(child_pipe *child, int value, vertex *v)
/* Procedure forks vertex. Child process will be initialized with [value] as *
 * value, count equal to one and pipes duped into {0, 1} descriptors.        *
 * Parent process populates [child] structure with analogical descriptors    *
 * providing way to communication. Then sends confirmation signal into       *
 * output.                                                                   *
 *                                                                           *
 * MUTABLE PARAMETERS: v, child                                              */
{
  int result = 1;
  int *in = make_pipe(), *out = make_pipe();
  switch(fork())
  {
    case -1:
      syserr("fork failed");
      break;
    case 0:
      setup_child(in, out);
      vertex_init(v, value);
      break;
    default:
      setup_parent(child, in, out);
      checked_write(1, &result, sizeof(result));
      break;
  }
  free(in);
  free(out);
  return ;
}
Beispiel #2
0
int main(int argc, char* argv[]) {
	setup_parent("domain", argc, argv);
}