Subject: bug#11102: 24.0.94; C-x C-c from a client frame sometimes kills the whole Emacs process

From: Eli Zaretskii <[email-masked]>
Date: Sat, 14 Apr 2012 10:25:42 +0300

> From: Chong Yidong <[email-masked]>
> Cc: Juanma Barranquero <[email-masked]>,  [email-masked]
> Date: Sat, 14 Apr 2012 13:34:27 +0800
> 
> Chong Yidong <[email-masked]> writes:
> 
> > If on a client frame created by "emacsclient -c -n" the C-x C-c command
> > kills Emacs, that is indeed a bug.  My guess would be that the `client'
> > frame parameter is not getting correctly assigned to the newly-created
> > frame on Windows, due to the extra juggling in the #ifdef WINDOWSNT code
> > segment Juanma pointed out.
> 
> Took a quick look, and indeed the "set tty = 1 on Windows" hack does
> seem to be at fault.

Like I said, I see the same "bug" on GNU/Linux, when the server runs
in a TTY session (couldn't check in a GUI session).  Are you talking
about GUI sessions only?

> Here's my diagnosis:
> 
>   if (tty || !current_frame)
>     {
>       display = (const char *) ttyname (0);  /* Arg is ignored.  */
>       current_frame = 0;
>       tty = 1;
>     }
> 
>   ...
> 
>   /* --no-wait implies --current-frame on ttys when there are file
>      arguments or expressions given.  */
>   if (nowait && tty && argc - optind > 0)
>     current_frame = 1;
> 
> When tty = 1, if there are also -n and filename arguments, emacsclient
> assumes that a current Emacs frame must be used.  This assumption is not
> correct if the tty = 1 is because of the Window hack.

But is that assumption correct if tty = 1 on GNU/Linux?  In a previous
mail you said:

> With the -c option, a client frame is created, so C-x C-c should delete
> the frame without killing the main Emacs session, whether or not there
> is an -n option.

This seems to imply that using "emacsclient -c -n FILE" on a Posix
host should _not_ kill emacs when "C-x C-c" is typed.  And yet in my
testing, it does, with the emacs-24 branch built just now, when the
server runs in a TTY session.  Are you saying that the effect of -n
depends also on whether the server runs in a TTY session?  If not,
what else am I missing?