title: child process write to file
body: <p>i have to make program, which will make two children processes. These processes will write something(string...) in file. Parent process should decide which process is going to write to file
  i have created children processes, but i am stuck at these signals and i don't have a clue how to do this</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;stdlib.h&gt;
  #define READY_SIGNAL SIGUSR1
  #define max 1000
  int main(int argc, char *argv[]) {
          FILE *file;
          int o;
          char *name;
      opterr = 0;
          while ((o = getopt(argc, argv, "hp:")) != -1)
                  switch (o) {
                          case 'h':
                          Help();
                          exit(1);
  
                          default:
                  exit(1);
          }
      argc -= optind;
      argv += optind;
          if(argc==0){
          printf("file name\n");
          scanf("%s",&amp;name);
          file=fopen(name,"a+");
          if( file != NULL)
          {
                  printf("file created\n");
                 // fclose(file);
           }
  
          else printf("the file does not exist\n");
  
          }
          else if(argc&gt;1) {
                  return(1);
          }
          else
                  meno=argv[0];
          file=fopen(name,"a");
          if( file != NULL){
          printf("file created\n");
          }
          else printf("the file does not exist\n");
  
  pid_t child_pid, child_pid2;
  
   printf ("the main program process ID is %d\n", (int) getpid());
  
   child_pid = fork () ;
   if (child_pid != 0) {
      printf ("this is the parent process, with id %d\n", (int) getpid ());
      printf ("the child's process ID is %d\n",(int) child_pid );
  }
   else {
     printf ("this is the child process, with id %d\n", (int) getpid ());
  exit(0);
  }
  
   child_pid2 = fork () ;
   if (child_pid2 != 0) {
      printf ("this is the parent process, with id %d\n", (int) getpid ());
      printf ("the child's process ID is %d\n",(int) child_pid2 );
  }
   else
  {
     printf ("this is the child process, with id %d\n", (int) getpid ());
     exit(0);
  }
   return 0;
  
  }
  </code></pre>
  
  <p>thanks</p>