bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils 5.2.1 -> 5.93 regression: With nohup getlogin() returns NU


From: Eric Blake
Subject: Re: coreutils 5.2.1 -> 5.93 regression: With nohup getlogin() returns NULL
Date: Wed, 21 Mar 2007 22:46:26 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.4.666

-----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             address@hidden
-----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-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]