Bug 279915 - "exec daemon konsole" fails
Summary: "exec daemon konsole" fails
Status: RESOLVED UNMAINTAINED
Alias: None
Product: konsole
Classification: Applications
Component: single-process (show other bugs)
Version: 2.6.4
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-11 16:52 UTC by Askar Safin
Modified: 2018-03-20 17:23 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Askar Safin 2011-08-11 16:52:16 UTC
Version:           2.6.4 (using KDE 4.6.5) 
OS:                Linux

"daemon" is tool to daemonize processes.
When I type "exec daemon konsole" to konsole, this command sometimes fails.
This bug appears both in Debian Squeeze and Debian Sid. I use version 0.6.4-1 of daemon.

Reproducible: Always

Steps to Reproduce:
I type "exec daemon konsole" to konsole. Window closes and new window appears (this is normal). Then I type this command again etc.

Actual Results:  
After several steps window closes, but new doesn't appear

Expected Results:  
Windows must appear infinite
Comment 1 Askar Safin 2011-08-12 05:08:17 UTC
"exec konsole" and "exec dolphin" fail, too
Comment 2 Askar Safin 2011-08-16 09:35:02 UTC
When there is a problem trace of "exec daemon konsole" is:

  unnamed app(9697): KUniqueApplication: Registering failed!
  unnamed app(9697): Communication problem with  "konsole" , it probably crashed.
  Error message was:  "org.freedesktop.DBus.Error.ServiceUnknown" : " "The name org.kde.konsole was not provided by any .service files" "

Also you can see our letters with Raf (author of "daemon") for more detailed information: http://paste.kde.org/110017/
Comment 3 Askar Safin 2011-08-26 22:01:10 UTC
Bug also appears in Debian's and Ubuntu's start-stop-daemon. Repeating (in konsole):

# cat << EOF > /tmp/k
> #!/bin/sh
> exec konsole "$@"
> EOF
# chmod +x /tmp/k
# exec start-stop-daemon -x /tmp/k -S
Comment 4 Jekyll Wu 2011-08-27 02:29:13 UTC
I do not quite understand what 'daemon' and 'start-stop-daemon' do, but I would like to remind you of a not-well-noticed behavior of konsole: it by default forks itself and runs in background, unless --nofork option is specified.  See bug #262169.

I have no idea of the expected result in that start-stop-daemon example, but replacing 'konsole' with  'konsole --nofork' will open a konsole window for me.
Comment 5 Askar Safin 2011-08-27 20:01:17 UTC
> I do not quite understand what 'daemon' and 'start-stop-daemon' do
They daemonize processes (and can do some additional work).
> I would like to remind you of a not-well-noticed behavior of konsole
This doesn't matter.
> I have no idea of the expected result in that start-stop-daemon example
Expected result is closing current konsole and opening another konsole. Actual result is closing current konsole and no opening.

Also, I forget "-b" option for start-stop-daemon. This option makes real daemonizing. So, command is: "start-stop-daemon -bx /tmp/k -S".

* start-stop-daemon should create and daemonize process "konsole"
* "-S" means "start" (not stop)
* "-x" means "path to executable"
* I use script /tmp/k instead of real /usr/bin/konsole, because start-stop-daemon doesn't start process, if we already have one

I did following experiment: http://paste.kde.org/115015/. So, I found another bug (2nd row in pastebin)!
Comment 6 Askar Safin 2011-08-28 08:19:34 UTC
Some another bugs:

Command: daemon -- konsole --nofork
Expected: new konsole opens
Actual: nothing

Command: exec daemon -- konsole --nofork
Expected: current closes and new opens
Actual: current closes
Comment 7 Jekyll Wu 2011-08-28 12:12:49 UTC
(In reply to comment #6)
> 

I got some clue. The actual behavior depends upon how the original konsole is stared. 

1) if the original konsole is started from menu or krunner(ps command shows it as "kdeinit4: konsole [kdeinit]"), it behaves as described in that comment.

2) if the original konsole is started from another terminal(say, xterm), it behaves as expected in that comment.
Comment 8 Askar Safin 2011-08-29 20:03:59 UTC
> if the original konsole is started from another terminal(say, xterm), it
behaves as expected in that comment.
I tested and got bugs again. I pressed Alt-F2, typed xterm, then typed konsole to xterm and then typed "daemon -- konsole --nofork" to konsole. Now window didn't appear.
Comment 9 Askar Safin 2011-09-06 20:31:16 UTC
I understand all!
"konsole" sometimes cannot work if stdout is /dev/null, for example:

# konsole --nofork > /dev/null
<unknown program name>(2946)/: KUniqueApplication: Can't setup D-Bus service. Probably already running.

(expected: new window opens, actual: error)

But all daemonizing programs redirect stdout to /dev/null, so "konsole" fails.
But I think there is another bugs, because following doesn't work:

# exec daemon sh -c 'exec konsole > /tmp/out'
(expected: current window closes, new opens, actual: current closes)
Comment 10 Askar Safin 2011-09-06 20:36:32 UTC
> if the original konsole is started from another terminal(say, xterm), it
behaves as expected in that comment
Sorry, you are right. If I start konsole from menu and type "exec daemon konsole", it will fail. If I start konsole form another konsole, it doesn't fail.

Also, read prev. comment!
Comment 11 Askar Safin 2012-01-15 15:02:48 UTC
* "konsole --nofork > /dev/null" bug fixed (see bug 288200)

* "exec daemon konsole" bug still exists

* If you don't want to deal with "daemon", "start-stop-daemon" etc, I recommend another command: "trap '' HUP; setsid konsole < /dev/null > /dev/null 2> /tmp/log & exit". This command actually daemonizes konsole without special tools. Also you can see error message in /tmp/log:

unnamed app(2118): Communication problem with  "konsole" , it probably crashed.
Error message was:  "org.freedesktop.DBus.Error.NoReply" : " "Message did not receive a reply (timeout by message bus)" "

* Bug exists only if konsole started from menu, icon or by command "kdeinit4 konsole" from xterm

* Bug depends of Linux kernel version!! o_O I can reproduce bug on Debian Sid or Wheezy with "linux-image-3.0.0-12-generic" from Ubuntu with proprietary blobs. But I cannot reproduce on the same system with "linux-image-3.1.0-1-amd64" from Debian without proprietary blobs

* I think reason is following: when I type "trap...", new konsole runs, but old still running too. New konsole runs function KUniqueApplication::start(...) from libkdeui and forks (in this function). Child tries to register in DBus, but DBus says that service already registred (because old konsole runs). Then old konsole terminates, and parent tries to connect to DBus. But it cannot, because old konsole terminated and service is not registred anymore. So, parent prints: "Communication problem..."

* When I add debug output, bug disappears o_O. This is Heisenbug. Bug is very sensible to time intervals

* This is better way to reproduce bug: run konsole from menu (or icon), type "trap...". If new konsole window appear, close it and run konsole from menu again etc

*************
I think bug is very hard to fix, because one cannot make atomic registering in DBus in one process and connecting to it in another process. So, I want to ask developers: it is really important (and possible) to fix the bug? If no, I will remove this bug with "RESOLVED/LATER" or something like that
Comment 12 Askar Safin 2012-01-15 15:03:06 UTC
Ooops
Comment 13 Jekyll Wu 2012-01-19 16:44:46 UTC
Hi Askar Safin :

Thanks for your feedback and investigation !

Frankly, I don't know whether this problem can be easily fixed at the moment. And I personally do not take this problem with high priority. I would bet over 99% of konsole users had never used or will use konsole in this way :)

But it is better to leave this report open for a while. It is a good example of the side effect of konsole using KUniqueApplication. And maybe I will find some workaround sometime later.
Comment 14 Askar Safin 2017-02-18 13:55:15 UTC
What happened? Why closed with RESOLVED UNMAINTAINED?
Comment 15 Kurt Hindenburg 2017-02-18 17:00:21 UTC
KDE4 is not maintained any longer as there won't be any new releases. 

The newest KF5 versions have changed how the --nofork and process / tab works.
Comment 16 Ahmad Samir 2018-03-20 17:23:43 UTC
Closing per comment 15.