title: gdb remote debugging of c++ process started via ssh: how to redirect stdin
body: <p>First, some background. I run a program by starting a process on a <code>remote_host</code> using <code>ssh</code>:</p>
  
  <pre><code>ssh -T remote_host "cd ~/mydir &amp;&amp; ~/myprogram" &lt; input.txt
  </code></pre>
  
  <p>The program, <code>myprogram</code>, reads stdin, which is attached to a local file <code>input.txt</code>.</p>
  
  <p>Now, I need to remotely debug this program under gdb. If there was no stdin redirection, i.e. <code>&lt; input.txt</code>, I would be able to do this using gdb's <code>target remote</code>, something like this (at gdb prompt):</p>
  
  <pre><code>(gdb) target remote | ssh -T remote_host gdbserver - myprogram
  </code></pre>
  
  <p>However, in the above example, I don't know how to attach <code>myprogram</code>'s stdin to <code>input.txt</code>.</p>
  
  <p>Is there something that would do the trick? </p>