summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/tty.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/tty.cc')
-rw-r--r--winsup/cygwin/tty.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc
index 242a2a846..371887c20 100644
--- a/winsup/cygwin/tty.cc
+++ b/winsup/cygwin/tty.cc
@@ -81,12 +81,18 @@ create_tty_master (int ttynum)
{
/* Log utmp entry */
struct utmp our_utmp;
+ DWORD len = sizeof our_utmp.ut_host;
bzero ((char *) &our_utmp, sizeof (utmp));
(void) time (&our_utmp.ut_time);
strncpy (our_utmp.ut_name, getlogin (), sizeof (our_utmp.ut_name));
- cygwin_gethostname (our_utmp.ut_host, sizeof (our_utmp.ut_host));
+ GetComputerName (our_utmp.ut_host, &len);
__small_sprintf (our_utmp.ut_line, "tty%d", ttynum);
+ if ((len = strlen (our_utmp.ut_line)) >= UT_IDLEN)
+ len -= UT_IDLEN;
+ else
+ len = 0;
+ strncpy (our_utmp.ut_id, our_utmp.ut_line + len, UT_IDLEN);
our_utmp.ut_type = USER_PROCESS;
our_utmp.ut_pid = myself->pid;
myself->ctty = ttynum;