Subject: bug#68799: 30.0.50; emacs --fg-daemon fails silently if server-start fails

From: Björn Bidar <[email-masked]>
Date: Wed, 14 Feb 2024 17:10:39 +0200

Eli Zaretskii <[email-masked]> writes:

>> Cc: [email-masked]
>> Date: Tue, 13 Feb 2024 23:30:41 +0200
>> From:  Björn Bidar via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email-masked]>
>> 
>> A side effect of this bug and another is that when emacs --fg-daemon is
>> used e.g. in combination with a systemd service. If the service
>> takes to long to be ready when a user calls emacsclient that it using
>> the standard desktop file it creates another daemon which will then
>> make the Emacs started with --fg-daemon fail resulting in the emacs in
>> the systemd service fail in circles.
>
> Please tell more details about the scenario you have in mind, because
> I don't think I follow.  In particular, why would starting the daemon
> take too long? due to what problems?  And how is user invoking
> emacsclient relevant in this case?  AFAIU, systemd starts Emacs at
> system start or user login time, whereas emacsclient is invoked when
> the user wants to run some command or clicks a desktop shortcut, and
> those events are not adjacent in time.
>
0. User logs in
1. The session reaches graphical-session.target
2. Emacs executed in emacs.service 
3. Emacs launches with all it's modes loaded, desktop-mode session
restored etc.
4. Emacs is ready to receive commands

When the user starts emacsclient before step 4 is reached then it can
timeout because it can take some time till Emacs is ready.

Step 1. Starts all parts of the programs which require a graphical
session including the desktop environment that the user is likely to
call upon emacsclient.