Skip to content

disowned XTerm process should remain running when 1st bash exits #1511

Closed

Description

@jamesdavidhoward

After starting a process from the 1st (& only) running bash shell, I can use the disown built-in shell command to (supposedly) divorce the 2nd process from the 1st and make it immune from the termination of the 1st bash process. (This works OK on "real" Linux.) However, it appears that in WSL, that the whole subsystem is terminated when this 1st bash shell is killed (as by exit).

I understand that there is arguably little reason to continue the life of the WSL subsystem after the very last Linux process has exited. However, any started, then disowned, process is still a working, valid Linux process. (In this case, it was xterm, talking to a local Windows-native X11 Server, and displaying on-screen as a command line window - itself running its own bash shell.) When the bash shell running in a WSL console command-line window exits, it should not take the xterm with it!

The still-running xterm should be enough to keep the WSL subsystem aware it is needed, and to be kept running, supporting the xterm (and any other processes that have been started).

Activity

  1. fpqc commented on Dec 16, 2016

    @fpqc

    This is how the system works right now by design, although they have fixes on the backlog. The workaround is using something called run.exe (search the issues page). Please close.

  2. jamesdavidhoward commented on Dec 16, 2016

    @jamesdavidhoward
    Author

    That is not my understanding; the lifetime of the Linux-supporting WSL subsystem was supposed to run as long as there were running Linux processes. (The issue of starting daemons or other services, without 1st invoking a bash shell is a different thing. That daemon/services issue is what I understood to be Backlogged, as commented by MSFT's Rich Turner [@richturn_ms]...)

  3. fpqc commented on Dec 16, 2016

    @fpqc

    Nope, you need to have at least one Linux process attached with active io handles to at least one Windows console (and the solution is basically to have Windows hide the console). The service counts for active handles, and when all active handles are gone, it shuts itself down.

  4. aseering commented on Dec 17, 2016

    @aseering
    Contributor

    jamesdavidhoward -- my understanding matches that of fpqc .

    There's a UserVoice here requesting the behavior that you are assuming, as well as proposing some workarounds.

  5. Efreak commented on Dec 18, 2016

    @Efreak

    A shortcut to the .vbs file below with the command you want to run (I suggest bash -c 'sleep Infinity' to avoid accidentally killing it) as an argument will run the command prompt hidden.

    CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

    Alternatively, you can use either cerebrate/wabash, the run.exe mentioned by fpqc, or something like my startwsl.vbs. Any of these will give you a persistent session, which will allow you to run processes in the background, though I recommend a vbs script as it's a single-file that's easier to modify and copy to other computers.

  6. fpqc commented on Dec 18, 2016

    @fpqc

    Efreak (@Efreak) If you're on 14986, you can do your session as opening tmux maximized (not suggested on earlier builds due to pty bugs).

  7. Brian-Perkins commented on Nov 22, 2017

    @Brian-Perkins
    Contributor

    Windows Insider Build 17046 allows programs to execute without an active terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions