------- Comment #7 from ebb9 at byu dot net 2007-03-22 04:46 ------- According to POSIX, "The getlogin() function shall return a pointer to a string containing the user name associated by the login activity with the controlling terminal of the current process." The behavior of nohup was intentionally changed in 5.90, as permitted by POSIX: "If stdin is a terminal, nohup now redirects it from /dev/null to prevent the command from tying up an OpenSSH session after you logout." The difference in behavior, then, is explainable by the fact that the child app no longer has a controlling terminal, therefore there is no login user to be found. In my mind, this is considered a feature of coreutils' nohup and not a bug. And since POSIX permits either behavior (preserving stdin and keeping a controlling terminal, vs. redirecting stdin and thereby disassociating from a terminal), it means that getlogin() is not portable in a nohup environment.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31299