title: Create new process in separate function [c]
body: <p>I wanna create spare process (child?) in specific function called eg. void process(). I want just to create that child process and do nothing with it. I just wanna it alive and do nothing while main() of my app will be working as I want. 
  In some point of my app's main() I will be killing child process and then respawn it again. Any ideas how to do that ? </p>
  
  <p>I have something like that but when I'm using this function to create process I get everything twice. Its like after initiation of process() every statement is done twice and i dont want it. After adding sleep(100) after getpid() in child section seems working fine but I cannot kill it.</p>
  
  <pre><code>int process(int case){
  
     if(case==1){
              status=1;
              childpid = fork();      
              if (childpid &gt;= 0) /* fork succeeded */
              {
                  if (childpid == 0) /* fork() returns 0 to the child process */
                  {
                      printf("CHILD  PID: %d\n", getpid());
                  }
          /* fork() returns new pid to the parent process *//*        else 
                  {
                  }*/
              }
              else
              {
                  perror("fork"); 
                  exit(0); 
              }
      }  
      else{
          if(status!=0){
              status=0;
              //kill!!!!
  
              system(a); //getting kill -9 PID ; but PID is equal 0 here...
              printf("\nkilling child");
          }
      }           
      }
  </code></pre>
  
  <p>how to just spawn new child process and let it just exist, like some sort of worker in C#?</p>