Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Tue, 5 Aug 2003 01:45:48 +0200 (MEST) From: Pavel Tsekov To: cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="========GMXBoundary325291060040748" Subject: [BUG] pututline () & rxvt: rxvt leaves stale utmp entries X-Priority: 3 (Normal) X-Authenticated-Sender: #0014308112 AT gmx DOT net X-Authenticated-IP: [217.110.55.71] Message-ID: <32529.1060040748@www44.gmx.net> X-Flags: 0001 Note-from-DJ: This may be spam --========GMXBoundary325291060040748 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Hello, On rxvt startup two utmp entries are created - the first one is created by Cygwin and the second one is created by rxvt itself: $ who Administ tty1 Aug 5 01:26 (MORDOR) Administ tty2 Aug 5 01:26 (:0) After rxvt shutdown: $ who Administ tty2 Aug 5 01:26 (:0) The cause for this seems to be that rxvt assumes that the return value of getutid () is usable in a call to pututline (), which doesn't seem to hold true on Cygwin. It turns out that Cygwin uses the same static variable to return utmp entries to the caller and also for its own internal purposes i.e. searching for the right utmp entry. I don't know if Cygwin is right or not in this case, and there doesn't seem to be a lot of documentation on this topic. The linux man pages tells that the return value of getutid(), getutline() and getutent() is a static memory but doesn't say anything about what could possibly happen if one uses it back in a call to pututline(). So I guess the behaviour is pretty much undefined. On the other hand there is a comment in the Cygwin source of logout() which indicates that the author of putline () was aware of this behaviour so I draw the conclusion that it is not a bug in Cygwin: /* We can't use ut further since it's a pointer to the static utmp_data area (see below) and would get overwritten in pututline(). So we copy it back to the local ut_buf. */ I've created a simple testcase (attached) which when ran on Linux produces the results that rxvt expects. Unfortunately currently I do not have access to any other unices on which I can run the testcase. Pavel -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -------------------------------------------------- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post --========GMXBoundary325291060040748 Content-Type: application/octet-stream; name="ut.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="ut.c" I2luY2x1ZGUgPHN5cy90eXBlcy5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDx1dG1w Lmg+CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CgppbnQgbWFpbiAoaW50 IGFyZ2MsIGNoYXIgKiphcmd2KQp7CiAgaW50IGk7CiAgY29uc3QgY2hhciAqbjsKICBzdHJ1Y3Qg dXRtcCB1LCAqcHU7CgogIG4gPSB0dHluYW1lIChTVERJTl9GSUxFTk8pOwogIHByaW50ZiAoIlRl cm1pbmFsIG5hbWUgaXM6ICVzXG4iLCBuKTsKCiAgbWVtc2V0ICgmdSwgJ1wwJywgc2l6ZW9mICh1 KSk7CiAgdS51dF90eXBlID0gVVNFUl9QUk9DRVNTOwogIHN0cmNweSAodS51dF9saW5lLCBuKTsK ICBpZiAoIXN0cm5jYXNlY21wIChuLCAiL2Rldi8iLCA1KSkKICAgIHN0cm5jcHkgKHUudXRfbGlu ZSwgbiArIDUsIFVUX0xJTkVTSVpFKTsKICBlbHNlCiAgICBzdHJuY3B5ICh1LnV0X2xpbmUsIG4s IFVUX0xJTkVTSVpFKTsKCiAgZm9yIChpID0gMDsgaSA8IDI7IGkrKykKICAgIHsKICAgICAgdS51 dF9pZFswXSA9ICdhJyArIGk7CiAgICAgIHNldHV0ZW50ICgpOwogICAgICBwdXR1dGxpbmUgKCZ1 KTsKICAgICAgcHJpbnRmICgiV3JvdGUgdXRtcCBlbnRyeTogdHlwZSAlZCwgaWQgJXMsIGxpbmUg JXNcbiIsIHUudXRfdHlwZSwKCSAgICAgIHUudXRfaWQsIHUudXRfbGluZSk7CiAgICB9CgogIHNl dHV0ZW50ICgpOwogIHB1ID0gZ2V0dXRpZCAoJnUpOwogIHByaW50ZiAoIkNhbGxpbmcgZ2V0dXRp ZCAoKSB3aXRoIGlkICVzOiBpZCA9ICVzLCBsaW5lID0gJXNcbiIsIHUudXRfaWQsIHB1LT51dF9p ZCwgcHUtPnV0X2xpbmUpOwogIHB1LT51dF9saW5lWzBdID0gJ1QnOwogIHByaW50ZiAoIkFib3V0 IHRvIHdyaXRlIHRoZSBmb2xsb3dpbmcgdXRtcCBlbnRyeTogaWQgJXMsIGxpbmUgJXNcbiIsIHB1 LT51dF9pZCwgcHUtPnV0X2xpbmUpOwogIHNldHV0ZW50ICgpOwogIHB1dHV0bGluZSAocHUpOwog IHByaW50ZiAoIkNhbGxpbmcgcHV0dXRsaW5lICgpIHdpdGggaWQgJXMsIHNldHRpbmcgbGluZSB0 byAlc1xuIiwgcHUtPnV0X2lkLCBwdS0+dXRfbGluZSk7CgogIGZvciAoaSA9IDA7IGkgPCAyOyBp KyspCiAgICB7CiAgICAgIHUudXRfaWRbMF0gPSAnYScgKyBpOwogICAgICBzZXR1dGVudCAoKTsK ICAgICAgcHUgPSBnZXR1dGlkICgmdSk7CiAgICAgIHByaW50ZiAoIkNhbGxpbmcgZ2V0dXRpZCAo KSB3aXRoIGlkICVzOiBpZCA9ICVzLCBsaW5lID0gJXNcbiIsIHUudXRfaWQsIHB1LT51dF9pZCwg cHUtPnV0X2xpbmUpOwogICAgfQoKICBlbmR1dGVudCAoKTsKICBleGl0ICgwKTsKfQo= --========GMXBoundary325291060040748 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --========GMXBoundary325291060040748--