Announcement

Collapse
No announcement yet.

konsole killing child processes on exit, and midnight commander...

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    konsole killing child processes on exit, and midnight commander...

    Scenario 1:

    I am in a konsole bash session. I run this command:

    konsole
    ...and then in that window I run midnight commander with

    mc
    ...then open an mp3 file in vlc, and then go back to the mc window and hit control-c, midnight commander exits, and then I "exit" the konsole window and the vlc process continues to run, as desired.


    Scenario 2:

    I am in a konsole bash sesion and enter:

    konsole -e mc
    ...and then use mc to open an mp3 file with vlc. Then when I ctrl-c in midnight commander, both the konsole window and vlc die.


    Why is running the command in konsole with -e causing its child processes to die when it dies, but opening it without -e and running a child process does not cause this? I notice that in scenario 1, if instead of typing "exit" I instead alt-f4 and kill the window, then it does kill vlc, just like in scenario 2. From this I deduce that when you ctrl-c a process in a "konsole -e" session, it sends SIGHUP or SIGKILL or whatever to all child processes.

    The reason I'm struggling with this is that I want to call up mc with a keyboard shortcut, be able to spawn child processes (like vlc playing a file) and the ctrl-c the mc window and have the vlc survive, but I can't figure out how to make it work.

    Any idea of how I can tell konsole that the -e process should live on as a background process? Or any other way around this? I tried going into the menu of mc and doing exit that way (rather than ctrl-c) but it had the same result.

    #2
    Man, I'm really pulling my hair out on this one. I've tried six different convoluted methods and can't find a solution...

    It seems like the rule is "when a command is started via konsole -e, or via krunner, or even xterm -e, then when that process exits, slaughter all the child processes no matter what."

    Another example:

    - in konsole, run "konsole -e bash"
    - in that new konsole/bash shell, run "vlc &"
    - now, if you "exit" from the bash shell, vlc continues to live. But if you alt-F4 the konsole window, vlc dies with the konsole. Why?
    - if instead of "exit" you run "disown" and then alt-F4 the konsole window, vlc does not die.

    Great, so if we just "disown" within the bash shell, it's children will live on even if the konsole window is killed!

    However:

    - make /tmp/myscript and mark it executable with the following contents:
    #!/bin/bash
    vlc &
    disown
    sleep 4
    - from a konsole window run "konsole -e /tmp/myscript"... as soon as the sleep expires, everything dies, including vlc. Why? This also happens for xterm -e. However at this point krunner will actually work (!?).

    However: if I add a nohup:

    #!/bin/bash
    nohup vlc &
    disown
    sleep 4


    ...it does not die when started with konsole -e. Great, so I can just use nohup!

    However: in my scenario I need to use xdg-open, not vlc, and xdg-open (by way of kde-open5) just returns without any information about what was launched. So even if I "nohup xdg-open" is has no effect because the "real" process wasn't nohup'ed, and everything dies whenever the konsole window exits.

    Any ideas? All I want to do is use mc to launch apps and then go away without tearing everything down when it closes... seems like it shouldn't be this darn hard!

    Comment

    Users Viewing This Topic

    Collapse

    There are 0 users viewing this topic.

    Working...
    X