title: Testing if my program is executed from the bash/ksh/csh command line
body: <p>I would like to know if my program is executed from a command line, or executed through <code>system()</code> call, or from a script.</p>
  
  <p>I initially thought about getting parent id (<code>getppid()</code>), and looking up <code>/proc/#pppid</code> directory checking either the <code>exe</code> link or contents of the <code>cmdline</code> file. If it is /bin/bash, or /bin/csh, or /bin/sh I would know that it runs from the command line.</p>
  
  <p>The problem is that it is <strong>not true</strong>, because a standalone script would also tell me <code>/bin/bash</code>.
  Even if it worked, it could have been very specific Linux version approach and could stop working in a future.</p>
  
  <p>Is there a better way to do that?</p>
  
  <p>Thank you for any advice or pointing out to some direction.</p>