title: How to pass a background process to the foreground in C
body: <p>I have to implement a function (Shell) that converts the background process identifier in a process pid in the foreground (waiting for it to finish).</p>
  
  <p>I have this code: </p>
  
  <pre><code>if (sscanf(args[1], "%d", &amp;pid_leido) == 1) { //read the pid 
              pid = (pid_t)pid_leido;
  
              if ((lp=getPid(lp, pid)) == NULL)
                  printf("Proccess %s not found\n", args[1]);
              else { //if exists process with this pid 
                        (waitpid(pid, NULL, 0) == -1) // i wait?¿?¿ 
                      perror(" wait4"); 
              }
  </code></pre>
  
  <p>Thanks ... </p>