Check if program is being piped
<p>I'm writing a program that speeds up the <code>git push</code> operation. Here's what it needs to do:</p>

<pre><code>printf("[github-username]\n[github-password]");
</code></pre>

<p>I'd then use it like so:</p>

<pre><code>git-autologin | git push
</code></pre>

<p>But I don't want there to be any chance of someone simply typing <code>git-autologin</code> or <code>git-autologin &gt; file.txt</code> and being able to see my username and password. I know it sounds silly 'cause anyone can still automate the git commands but it's unlikely that any untrusted user will ever get on my system.</p>

<p><strong>My question:</strong> How could I tell if standard output is writing to a file/terminal or if it's being piped?<br>
<strong>Edit:</strong> The <code>git push</code> pipe was simply an idea, not the only reason I'm asking.<br>
<strong>Edit:</strong> Is there any way to determine the PID or more information about the process it's being piped to?</p>