Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[screen is terminating] #774

Closed
gaia opened this issue Aug 5, 2016 · 18 comments
Closed

[screen is terminating] #774

gaia opened this issue Aug 5, 2016 · 18 comments

Comments

@gaia
Copy link
Contributor

gaia commented Aug 5, 2016

When I run [sudo screen] I get only [screen is terminating].

If I [su] I still get the same behavior.

user@machine:~$ ll /usr/bin/screen
-rwxr-sr-x 1 root utmp 421768 Nov 7 2013 /usr/bin/screen*

@fpqc
Copy link

fpqc commented Aug 5, 2016

Not sure what the problem with Screen is right now, but tmux is working.

@gaia
Copy link
Contributor Author

gaia commented Aug 5, 2016

@fpqc same here.

@poschi3
Copy link

poschi3 commented Aug 5, 2016

When I run screen without sudo i get the message:
Cannot make directory '/var/run/screen': Keine Berechtigung

@gaia
Copy link
Contributor Author

gaia commented Aug 5, 2016

@poschi3 yes, IMHO that's default behavior in WLS.

@benhillis
Copy link
Member

One of the developers on the team is currently working on getting screen working.

@fpqc
Copy link

fpqc commented Aug 5, 2016

@benhillis It's fine anyway tmux is way better!!

@rodrigo-a-moreno
Copy link

same here... I got /var/run/utmp does not exists and the [screen is terminating], I created that file but now I don't get any error message but then got [screen is terminating]

@fpqc
Copy link

fpqc commented Aug 13, 2016

@Freakzoid use tmux in the mean time. One of the devs even said this isn't done yet.

@russalex
Copy link
Contributor

Time for an update.

Try [sudo screen] again on build 14915. There are still some issues with the function keys, but I was able to create new screens and navigate using ctrl-a c / n.

@likan999
Copy link

Has the fix pushed to non-preview systems? My Win10 doesn't have insider-preview enabled, and I still can't run sudo screen as of today (it is up-to-date), therefore can't run sudo do-release-upgrade. How should I work-around this issue? I don't want to uninstall and reinstall.

@benhillis
Copy link
Member

benhillis commented Jan 13, 2017

@likan999 - this issue will be resolved for non-preview builds when Windows 10 Creator's Update releases (early 2017).

@sbull
Copy link

sbull commented Jul 7, 2017

For future WSL users trying to run screen without sudo, but get
Cannot make directory '/var/run/screen': Permission denied:

In standard ubuntu boots, startup scripts automatically create the /var/run/screen/ directory as root. WSL does not run ubuntu's standard startup scripts, so /var/run/screen/ does not get automatically created when you launch WSL's bash. Running screen as root (sudo screen) automatically creates the required /var/run/screen/ dir with appropriate permissions, allowing you to then run screen as a normal user.

/var/run is mounted as a temporary filesystem that automatically gets clobbered with each reboot. When you close the bash terminal (or close the last one if you had opened multiple), it acts like a power-off of the WSL system, causing the tmpfs /var/run to be wiped clean. So you need to run screen as root every time you start WSL in order to run screen as a normal user.

To enable this to happen automatically and just use screen as a normal user whenever you start WSL, an option is to run a screen command as root from your ~/.bashrc startup file (WSL's bash does not run as a login shell, so ~/.profile doesn't work). You can make something run as root (without sudo) by creating an executable binary owned by root with the setuid bit set (shell scripts don't work). The recipe is as follows:

  1. Create the text file ~/screen-setup.c with the following content:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid(0);
system("/usr/bin/screen -ls");
return 0;
}
  1. Install gcc:
    sudo apt-get install build-essential

  2. Compile the file to an executable binary:
    gcc screen-setup.c -o screen-setup

  3. Set the appropriate ownership & permissions:
    sudo chown root:root screen-setup
    sudo chmod 4555 screen-setup

  4. Add the following line to ~/.bashrc:
    ~/screen-setup > /dev/null

That recipe will make screen work as your normal user whenever you start WSL.

setuid binary executable reference

@radonthetyrant
Copy link

hello @sbull
i think this issue has been resolved in the creators update

can you reproduce the issue with a version equal or after OS Build 15063.447?

@sbull
Copy link

sbull commented Jul 7, 2017

I'm running 15063.413. My comment is about how to just be able to run screen as a normal user when you launch WSL, not about running screen as root. Yes, screen is working for me, but this issue is what I found while looking for problems running screen on WSL, so it seems like the right place to note how to do it. Sorry if that's confusing from an issue tracking perspective, but I couldn't find any other documentation about running startup scripts in WSL like would normally happen to enable screen for non-root users by creating the necessary directory in /var/run automatically.

@joegrasse
Copy link

@sbull I had this exact issue. Thank you for an easy fix.

@tvasenin
Copy link

Thanks, @sbull !

The issue with non-sudo screen still exists in 16299.64.
Please, reopen the issue.

@WSLUser
Copy link

WSLUser commented Nov 15, 2017

Bigger issue that needs resolving is having the all the standard startup scripts native Ubuntu runs being supported to run automatically upon launching a Ubuntu.exe console. I would go further and say OpenSuse is most likely experiencing the same issue of startup scripts and should be addressed as well. Long term goal I would say is to look higher level and make it so all current and future distros are able to load and run their startup scripts by default upon user logon (and eventually physical machine boot-up instead) on machines that have WSL installed. Part of this solution (and solution to other errors that pop up) is to emulate the kernels each Linux distro utilizes since there is no actual kernel in WSL for the Linux distros.

@bjoernmartin
Copy link

@sbull thanks for your proposed patch! Just one comment that might help others to get it running (did not run out of the box for me).

Executing system("/usr/bin/screen -ls"); results in the output No Sockets found in /var/run/screen/S-root for me (Win build 16299). I therefore changed the line to "fake" resuming an existing screen session via system("/usr/bin/screen -r 12345");. That works for me, I can now start a screen session right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests