title: Java Runtime.getRuntime.exec() returns null but returns valid String in shell
body: <p>I've been writing a class to find the real userID, using the linux binary <code>/usr/bin/logname</code> that returns the current user associated with my TTY. The command works fine in shell.</p>
  
  <pre><code>/usr/bin/logname
  scott
  </code></pre>
  
  <p>But I cannot get the same as a String in java with the following code that I wrote.</p>
  
  <pre><code>private String currentUser;
  public void getRealUser() throws Exception{
          String cmd = "/usr/bin/logname";
          Process p = Runtime.getRuntime().exec(cmd);
          p.waitFor();
          BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
          this.currentUser = stdInput.readLine();
          System.out.println(currentUser);
  }
  </code></pre>
  
  <p>When I create the object, I am seeing <code>null</code> for the value <code>currentUser</code>, which means <code>stdInput.readLine();</code> is not outputting anything.</p>
  
  <p>Please let me know what am I doing wrong.</p>