-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Tobias Burnus on 3/21/2007 11:55 AM: > Transferred from: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31299 > > If one runs the following program: > ----------------------- > #include <stdio.h> > #include <unistd.h> > int main() > { > printf("%s\n", (NULL == getlogin())?"no":getlogin()); > return 0; > } > ------------------------- > via "/usr/bin/nohup a.out", nohup.out contains "no" with coreutils 5.93 > or 6.8 but using coreutils 5.2.1's nohup it contains the login name. > Calling the program in the shell or via tcsh's nohup prints also the > login name.
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. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGAgkF84KuGfSFAYARAp1zAKC5XKjLUN1u+kGikYJX6LBTse7hiQCfeDz6 f2Mcsbwurv/uzQePaaxJvio= =NRsR -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
