diff --git a/ChangeLog b/ChangeLog
index b9f9f730086ab68223f91bf8a1d432ac75349460..081d52b1e9b3fea456794d9d201b7ee75dba402b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-03-09  Niels M�ller  <nisse@lysator.liu.se>
 
+	* src/unix_process.c (utmp_book_keeping): Don't pass utmp's ut_tv
+	directly to gettimeofday, since for binary  compatibility, utmp may
+	use a different type.
+
 	* src/scm/guile-compat.scm: Use the rdelim module, for the
 	read-line function.
 
diff --git a/src/unix_process.c b/src/unix_process.c
index eff26a63fa0c4e24918be67901c7fd921926241d..a28676a548c2c871c9f192834185f452e4ca49fb 100644
--- a/src/unix_process.c
+++ b/src/unix_process.c
@@ -410,7 +410,15 @@ utmp_book_keeping(struct lsh_string *name,
 #endif
 
 #if UTMPX_UT_TV
-  gettimeofday(&entry.ut_tv, NULL); /* Ignore the timezone */
+  {
+    /* On 64-bit, glibc may use a private 32-bit variant of struct
+       timeval, for binary compatibility. So we can't always pass
+       &pty->entry directly to gettimeofday. */
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    entry.ut_tv.tv_sec = tv.tv_sec;
+    entry.ut_tv.tv_usec = tv.tv_usec;
+  }
 #else
 # if UTMPX_UT_TIME
   time(&entry.ut_time);