/* Session management module for systems which understand the X Session
management protocol.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <sys/param.h>
#include <stdio.h>
+#include "lisp.h"
#include "systime.h"
#include "sysselect.h"
-#include "lisp.h"
#include "termhooks.h"
#include "termopts.h"
#include "xterm.h"
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
-#endif /* not MAXPATHLEN */
-
-
/* The user login name. */
extern Lisp_Object Vuser_login_name;
int val_idx = 0;
int props_idx = 0;
- char cwd[MAXPATHLEN+1];
+ char *cwd = NULL;
char *smid_opt;
/* How to start a new instance of Emacs. */
props[props_idx]->vals[0].value = SDATA (Vuser_login_name);
++props_idx;
- /* The current directory property, not mandatory. */
-#ifdef HAVE_GETCWD
- if (getcwd (cwd, MAXPATHLEN+1) != 0)
-#else
- if (getwd (cwd) != 0)
-#endif
+ cwd = get_current_dir_name ();
+
+ if (cwd)
{
props[props_idx] = &prop_ptr[props_idx];
props[props_idx]->name = SmCurrentDirectory;
xfree (smid_opt);
+ if (cwd)
+ free (cwd);
+
/* See if we maybe shall interact with the user. */
if (interactStyle != SmInteractStyleAny
|| ! shutdown
DEFVAR_LISP ("x-session-previous-id", &Vx_session_previous_id,
doc: /* The previous session id Emacs got from session manager.
If Emacs is running on a window system that has a session manager, the
-session manager gives Emacs a session id. It is feasible for Emacs lisp
+session manager gives Emacs a session id. It is feasible for Emacs Lisp
code to use the session id to save configuration in, for example, a file
with a file name based on the session id. If Emacs is running when the
window system is shut down, the session manager remembers that Emacs was