title: Questions about using forkpty to create pseudo terminal to ssh in C
body: <pre><code>pid = forkpty (&amp;pty,0,0,0);
  if (pid == 0) {
      execl ("/usr/bin/ssh", "ssh", hostname, NULL);
      exit (0);
  } else if (pid &gt; 0) {
      ssh_pid = pid;
      ssh_pty = pty;
      if(child_ssh_success()) {
          get_user_input();
          send_user_input_to_child_ssh_and_child_forword_it_to_remote_server();
          get_remote_server_response_from_child();
          display_response_to_stdout();
      }
  }
  </code></pre>
  
  <p>How can I tell whether <code>ssh</code> success or not? </p>
  
  <p>How can parent know that child has successfully <code>ssh-ed</code> to remote server, so parent can send something to remote server?</p>