all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacsclient uses obsolete "server" file on Windows
@ 2008-06-07 18:05 djc
  2008-06-08 12:06 ` Juanma Barranquero
       [not found] ` <mailman.12907.1212926783.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: djc @ 2008-06-07 18:05 UTC (permalink / raw
  To: help-gnu-emacs

My _emacs contains

     (require 'server)
     (server-start)

When I kill emacs the "server" file remains. As a result, when I first invoke

     \path\emacsclientw.exe -a \path\runemacs.exe FILE

emacsclientw finds the obsolete "server" file, tries to use the information 
in it, and blocks with an error message saying the server has refused 
connection. (Actually, of course, the server doesn't exist.) Once I click 
to dismiss the message, everything proceeds fine: emacsclientw invokes 
runemacs, which starts emacs on the file. emacs writes a new, valid 
"server" file so further invoking the same command line works properly. It 
also works properly when there is no "server" file.

This can't possibly be how things are supposed to go. How should things be 
set up so the command above will always work without blocking? Hook 
deleting the file to "kill-emacs"?

I'm new to emacsclient after using gnuclient/gnuserv for years, so perhaps 
I've missed something obvious. If so, just point it out.  Thanks.

Pete


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-07 18:05 emacsclient uses obsolete "server" file on Windows djc
@ 2008-06-08 12:06 ` Juanma Barranquero
       [not found] ` <mailman.12907.1212926783.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Juanma Barranquero @ 2008-06-08 12:06 UTC (permalink / raw
  To: djc; +Cc: help-gnu-emacs

> When I kill emacs the "server" file remains.

How do you exit Emacs? And, which version are you using?

  Juanma




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
       [not found] ` <mailman.12907.1212926783.18990.help-gnu-emacs@gnu.org>
@ 2008-06-08 15:29   ` djc
  2008-06-08 20:38     ` Juanma Barranquero
       [not found]     ` <mailman.12919.1212957485.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: djc @ 2008-06-08 15:29 UTC (permalink / raw
  To: help-gnu-emacs

> How do you exit Emacs? And, which version are you using?

I exit with save-buffers-kill-emacs (files.el).

GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600) of 2008-03-26 on RELEASE

Pete


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-08 15:29   ` djc
@ 2008-06-08 20:38     ` Juanma Barranquero
       [not found]     ` <mailman.12919.1212957485.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Juanma Barranquero @ 2008-06-08 20:38 UTC (permalink / raw
  To: djc; +Cc: help-gnu-emacs

> I exit with save-buffers-kill-emacs (files.el).

FWIW, I think stopping the server should delete the authentication
file. Alas, it doesn't (and it is not a bug, it is so by design).

You can use this in your .emacs; it's not pretty, but it will help:

(require 'server)
(server-start)

(defvar my-server-file (expand-file-name server-name server-auth-dir))

(add-hook 'kill-emacs-hook
          (lambda ()
            (condition-case nil
                (delete-file my-server-file)
              (error nil))))

  Juanma




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
       [not found]     ` <mailman.12919.1212957485.18990.help-gnu-emacs@gnu.org>
@ 2008-06-08 20:52       ` djc
  2008-06-12  8:41       ` djc
  1 sibling, 0 replies; 19+ messages in thread
From: djc @ 2008-06-08 20:52 UTC (permalink / raw
  To: help-gnu-emacs

Thanks, Juanma.

I was afraid of that.  It's essentially the same thing I came up with.

Pete


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
       [not found]     ` <mailman.12919.1212957485.18990.help-gnu-emacs@gnu.org>
  2008-06-08 20:52       ` djc
@ 2008-06-12  8:41       ` djc
  2008-06-12  9:48         ` Juanma Barranquero
  1 sibling, 1 reply; 19+ messages in thread
From: djc @ 2008-06-12  8:41 UTC (permalink / raw
  To: help-gnu-emacs

Solved, using Juanma's code snippet.  Thanks a lot!

But what is the reason for the design decision not to delete the server 
authentication file when emacs is killed?

Pete


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12  8:41       ` djc
@ 2008-06-12  9:48         ` Juanma Barranquero
  2008-06-12 13:48           ` Lennart Borgman (gmail)
  2008-06-12 18:13           ` Eli Zaretskii
  0 siblings, 2 replies; 19+ messages in thread
From: Juanma Barranquero @ 2008-06-12  9:48 UTC (permalink / raw
  To: djc; +Cc: help-gnu-emacs

On Thu, Jun 12, 2008 at 10:41, djc <newsg@resiak.org> wrote:

> But what is the reason for the design decision not to delete the server
> authentication file when emacs is killed?

According to the comment in server.el, the risk of the server file not
being "ours" anymore:

  ;; Delete the associated connection file, if applicable.
  ;; This is actually problematic: the file may have been overwritten by
  ;; another Emacs server in the mean time, so it's not ours any more.
  ;; (and (process-contact proc :server)
  ;;      (eq (process-status proc) 'closed)
  ;;      (ignore-errors (delete-file (process-get proc :server-file))))

though I'd love to know how likely that is, vs. problems like the one
you reported.

    Juanma




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12  9:48         ` Juanma Barranquero
@ 2008-06-12 13:48           ` Lennart Borgman (gmail)
  2008-06-12 13:56             ` Juanma Barranquero
  2008-06-12 18:13           ` Eli Zaretskii
  1 sibling, 1 reply; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-12 13:48 UTC (permalink / raw
  To: Juanma Barranquero; +Cc: help-gnu-emacs, djc

Juanma Barranquero wrote:
> On Thu, Jun 12, 2008 at 10:41, djc <newsg@resiak.org> wrote:
> 
>> But what is the reason for the design decision not to delete the server
>> authentication file when emacs is killed?
> 
> According to the comment in server.el, the risk of the server file not
> being "ours" anymore:
> 
>   ;; Delete the associated connection file, if applicable.
>   ;; This is actually problematic: the file may have been overwritten by
>   ;; another Emacs server in the mean time, so it's not ours any more.
>   ;; (and (process-contact proc :server)
>   ;;      (eq (process-status proc) 'closed)
>   ;;      (ignore-errors (delete-file (process-get proc :server-file))))


Couldn't that be handled by checking the server file modification time?




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12 13:48           ` Lennart Borgman (gmail)
@ 2008-06-12 13:56             ` Juanma Barranquero
  2008-06-12 14:15               ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 19+ messages in thread
From: Juanma Barranquero @ 2008-06-12 13:56 UTC (permalink / raw
  To: Lennart Borgman (gmail); +Cc: help-gnu-emacs, djc

On Thu, Jun 12, 2008 at 15:48, Lennart Borgman (gmail)
<lennart.borgman@gmail.com> wrote:

> Couldn't that be handled by checking the server file modification time?

There's an inherent race condition: you cannot be sure that the file
will not be overwritten after you check its timestamp.

   Juanma




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12 13:56             ` Juanma Barranquero
@ 2008-06-12 14:15               ` Lennart Borgman (gmail)
  2008-06-12 14:33                 ` Juanma Barranquero
  0 siblings, 1 reply; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-12 14:15 UTC (permalink / raw
  To: Juanma Barranquero; +Cc: help-gnu-emacs, djc

Juanma Barranquero wrote:
> On Thu, Jun 12, 2008 at 15:48, Lennart Borgman (gmail)
> <lennart.borgman@gmail.com> wrote:
> 
>> Couldn't that be handled by checking the server file modification time?
> 
> There's an inherent race condition: you cannot be sure that the file
> will not be overwritten after you check its timestamp.

Are all writing process on the same machine so that a simple semaphore 
can be used?




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12 14:15               ` Lennart Borgman (gmail)
@ 2008-06-12 14:33                 ` Juanma Barranquero
  0 siblings, 0 replies; 19+ messages in thread
From: Juanma Barranquero @ 2008-06-12 14:33 UTC (permalink / raw
  To: Lennart Borgman (gmail); +Cc: help-gnu-emacs, djc

On Thu, Jun 12, 2008 at 16:15, Lennart Borgman (gmail)
<lennart.borgman@gmail.com> wrote:

> Are all writing process on the same machine

Not necesarily.

> so that a simple semaphore can be used?

A "simple semaphore" cannot be used from elisp.

Locking the file (with lock-buffer, though that does not work on
Windows) would be possible. IIRC, Stefan (who wrote that comment)
didn't want the second Emacs instance to get an error while trying to
write the file.

But, truth be told, I don't remember the issues well and I could be
misrepresenting his intention. I suggest you take a look at the
emacs-devel archives, a few months before 22.1 was released.

   Juanma




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12  9:48         ` Juanma Barranquero
  2008-06-12 13:48           ` Lennart Borgman (gmail)
@ 2008-06-12 18:13           ` Eli Zaretskii
  2008-06-12 18:20             ` Juanma Barranquero
  1 sibling, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2008-06-12 18:13 UTC (permalink / raw
  To: Juanma Barranquero; +Cc: help-gnu-emacs, newsg

> Date: Thu, 12 Jun 2008 11:48:36 +0200
> From: "Juanma Barranquero" <lekktu@gmail.com>
> Cc: help-gnu-emacs@gnu.org
> 
>   ;; Delete the associated connection file, if applicable.
>   ;; This is actually problematic: the file may have been overwritten by
>   ;; another Emacs server in the mean time, so it's not ours any more.
>   ;; (and (process-contact proc :server)
>   ;;      (eq (process-status proc) 'closed)
>   ;;      (ignore-errors (delete-file (process-get proc :server-file))))
> 
> though I'd love to know how likely that is, vs. problems like the one
> you reported.

On Windows, this can only happen if another instance of Emacs is
launched.  How probable is that?




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12 18:13           ` Eli Zaretskii
@ 2008-06-12 18:20             ` Juanma Barranquero
  2008-06-12 18:22               ` Eli Zaretskii
  2008-06-14  5:42               ` Bernardo Bacic
  0 siblings, 2 replies; 19+ messages in thread
From: Juanma Barranquero @ 2008-06-12 18:20 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs, newsg

On Thu, Jun 12, 2008 at 20:13, Eli Zaretskii <eliz@gnu.org> wrote:

> On Windows, this can only happen if another instance of Emacs is
> launched.  How probable is that?

I don't know. On my computer it is very likely, but I go to pains to
make sure every instance uses a different server-name, so there are no
conflicts.

For Windows users not involved in Emacs development, I'd say it is unlikely.

   Juanma




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12 18:20             ` Juanma Barranquero
@ 2008-06-12 18:22               ` Eli Zaretskii
  2008-06-12 18:24                 ` Juanma Barranquero
  2008-06-14  5:42               ` Bernardo Bacic
  1 sibling, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2008-06-12 18:22 UTC (permalink / raw
  To: Juanma Barranquero; +Cc: help-gnu-emacs

> Date: Thu, 12 Jun 2008 20:20:01 +0200
> From: "Juanma Barranquero" <lekktu@gmail.com>
> Cc: newsg@resiak.org, help-gnu-emacs@gnu.org
> 
> For Windows users not involved in Emacs development, I'd say it is unlikely.

I agree.  Then maybe, at least on Windows, we shouldn't be afraid
deleting the file.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12 18:22               ` Eli Zaretskii
@ 2008-06-12 18:24                 ` Juanma Barranquero
  0 siblings, 0 replies; 19+ messages in thread
From: Juanma Barranquero @ 2008-06-12 18:24 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Thu, Jun 12, 2008 at 20:22, Eli Zaretskii <eliz@gnu.org> wrote:

> I agree.  Then maybe, at least on Windows, we shouldn't be afraid
> deleting the file.

I'll bring the issue in the developers list.

   Juanma




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-12 18:20             ` Juanma Barranquero
  2008-06-12 18:22               ` Eli Zaretskii
@ 2008-06-14  5:42               ` Bernardo Bacic
  2008-06-14 10:57                 ` Eli Zaretskii
  2008-06-14 15:42                 ` Juanma Barranquero
  1 sibling, 2 replies; 19+ messages in thread
From: Bernardo Bacic @ 2008-06-14  5:42 UTC (permalink / raw
  To: Juanma Barranquero; +Cc: help-gnu-emacs

it was a dark and stormy night when Juanma Barranquero said, On 06/13/2008 
04:20 AM:
> On Thu, Jun 12, 2008 at 20:13, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> On Windows, this can only happen if another instance of Emacs is
>> launched.  How probable is that?
> 
> I don't know. On my computer it is very likely, but I go to pains to
> make sure every instance uses a different server-name, so there are no
> conflicts.
> 
> For Windows users not involved in Emacs development, I'd say it is unlikely.
> 

Haven't closely followed the thread, but in my case there are usually two 
independent instances of Emacs launched, one for code only, the other for 
"organisational stuff" - plans, todo lists, calendar, etc.
They are launched in separate directories so the corresponding .emacs.desktop 
files keep track of different settings. Either instance can go in and out of 
existence although most of the time both are running and because of the slack 
approach both start the 'server'.

--
Rgds, Bernardo




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-14  5:42               ` Bernardo Bacic
@ 2008-06-14 10:57                 ` Eli Zaretskii
  2008-06-14 23:33                   ` Bernardo Bacic
  2008-06-14 15:42                 ` Juanma Barranquero
  1 sibling, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2008-06-14 10:57 UTC (permalink / raw
  To: help-gnu-emacs

> Date: Sat, 14 Jun 2008 15:42:27 +1000
> From: Bernardo Bacic <bernardo.bacic@pobox.com>
> CC: Eli Zaretskii <eliz@gnu.org>, help-gnu-emacs@gnu.org
> 
> Haven't closely followed the thread, but in my case there are usually two 
> independent instances of Emacs launched, one for code only, the other for 
> "organisational stuff" - plans, todo lists, calendar, etc.
> They are launched in separate directories so the corresponding .emacs.desktop 
> files keep track of different settings.

Out of curiosity: why do you do that?  .emacs.desktop is perfectly
capable of tracking all your buffers, so why not open different frames
in the same session instead of two different sessions?




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-14  5:42               ` Bernardo Bacic
  2008-06-14 10:57                 ` Eli Zaretskii
@ 2008-06-14 15:42                 ` Juanma Barranquero
  1 sibling, 0 replies; 19+ messages in thread
From: Juanma Barranquero @ 2008-06-14 15:42 UTC (permalink / raw
  To: bernardo.bacic; +Cc: help-gnu-emacs

On Sat, Jun 14, 2008 at 07:42, Bernardo Bacic <bernardo.bacic@pobox.com> wrote:

> Haven't closely followed the thread, but in my case there are usually two
> independent instances of Emacs launched, one for code only, the other for
> "organisational stuff" - plans, todo lists, calendar, etc.
> They are launched in separate directories so the corresponding
> .emacs.desktop files keep track of different settings. Either instance can
> go in and out of existence although most of the time both are running and
> because of the slack approach both start the 'server'.

Hmm. If you use the same server-name in both instances, does that mean
that you don't use emacsclient, or that it is indifferent which Emacs
instance receives the files to be edited, or that you remember the
order you started the instances and do know which one is going to be
brought up?

  Juanma




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: emacsclient uses obsolete "server" file on Windows
  2008-06-14 10:57                 ` Eli Zaretskii
@ 2008-06-14 23:33                   ` Bernardo Bacic
  0 siblings, 0 replies; 19+ messages in thread
From: Bernardo Bacic @ 2008-06-14 23:33 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii said, On 06/14/2008 08:57 PM:
>> Date: Sat, 14 Jun 2008 15:42:27 +1000
>> From: Bernardo Bacic <bernardo.bacic@pobox.com>
>> CC: Eli Zaretskii <eliz@gnu.org>, help-gnu-emacs@gnu.org
>>
>> Haven't closely followed the thread, but in my case there are usually two 
>> independent instances of Emacs launched, one for code only, the other for 
>> "organisational stuff" - plans, todo lists, calendar, etc.
>> They are launched in separate directories so the corresponding .emacs.desktop 
>> files keep track of different settings.
> 
> Out of curiosity: why do you do that?  .emacs.desktop is perfectly
> capable of tracking all your buffers, so why not open different frames
> in the same session instead of two different sessions?

I just prefer working this way; the "code" instance will have easily 40+ files 
open at any time, the other one is much leaner and switching between buffers 
tends to get easier.
Switching buffers with two frames can land me in the other frame (if the 
buffer is already visible there) and often this is not what i want.
Guess this is just the mind thing, trying to keep things separate.




^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2008-06-14 23:33 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-07 18:05 emacsclient uses obsolete "server" file on Windows djc
2008-06-08 12:06 ` Juanma Barranquero
     [not found] ` <mailman.12907.1212926783.18990.help-gnu-emacs@gnu.org>
2008-06-08 15:29   ` djc
2008-06-08 20:38     ` Juanma Barranquero
     [not found]     ` <mailman.12919.1212957485.18990.help-gnu-emacs@gnu.org>
2008-06-08 20:52       ` djc
2008-06-12  8:41       ` djc
2008-06-12  9:48         ` Juanma Barranquero
2008-06-12 13:48           ` Lennart Borgman (gmail)
2008-06-12 13:56             ` Juanma Barranquero
2008-06-12 14:15               ` Lennart Borgman (gmail)
2008-06-12 14:33                 ` Juanma Barranquero
2008-06-12 18:13           ` Eli Zaretskii
2008-06-12 18:20             ` Juanma Barranquero
2008-06-12 18:22               ` Eli Zaretskii
2008-06-12 18:24                 ` Juanma Barranquero
2008-06-14  5:42               ` Bernardo Bacic
2008-06-14 10:57                 ` Eli Zaretskii
2008-06-14 23:33                   ` Bernardo Bacic
2008-06-14 15:42                 ` Juanma Barranquero

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.