Logging the ^d logoff

Doug Gwyn gwyn at brl-smoke.ARPA
Sat Feb 13 03:28:05 AEST 1988


In article <209 at mccc.UUCP>, pjh at mccc.UUCP (Peter J. Holsberg) writes:
> One suggestion, which came very close, was to trap 0 1 3 with a line in
> /etc/profile so that on ^d logout (or hangup, etc.) a line with "who am
> i" information would be written to /usr/.logins.  I found that this
> worked quite well except for one thing:  despite the fact that the login
> time is accurate, the logout time is always about one second after the
> login time, regardless of the actual logout!

I suspect the only problem is that you forgot that the arguments to the
"trap" built-in would be evaluated twice, once at the time of executing
the "trap" built-in, and once (with whatever the result of the first
evaluation was) when the trap fires at logout time.  Once you realize
this, the solution is obvious: quote the "who am i" so that it will not
be evaluated when "trap" is set.



More information about the Comp.unix.questions mailing list