/* Lock files for editing.
- Copyright (C) 1985, 86, 87, 93, 94, 96, 98, 1999, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1987, 1993, 1994, 1996, 1998, 1999, 2000, 2001,
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
#include <config.h>
#include <signal.h>
#include <stdio.h>
-#ifdef VMS
-#include "vms-pwd.h"
-#else
+#ifdef HAVE_PWD_H
#include <pwd.h>
-#endif /* not VMS */
+#endif
#include <sys/file.h>
#ifdef HAVE_FCNTL_H
char *host_name;
char *lock_info_str;
+ /* Call this first because it can GC. */
+ boot_time = get_boot_time ();
+
if (STRINGP (Fuser_login_name (Qnil)))
user_name = (char *)SDATA (Fuser_login_name (Qnil));
else
else
host_name = "";
lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name)
- + LOCK_PID_MAX + 5);
+ + LOCK_PID_MAX + 30);
- boot_time = get_boot_time ();
if (boot_time)
sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name,
(unsigned long) getpid (), (unsigned long) boot_time);
}
/* Parse USER@HOST.PID:BOOT_TIME. If can't parse, return -1. */
- /* The USER is everything before the first @. */
- at = index (lfinfo, '@');
+ /* The USER is everything before the last @. */
+ at = rindex (lfinfo, '@');
dot = rindex (lfinfo, '.');
if (!at || !dot)
{