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

Error message with ZSH and use of "&" in Creators Update #1887

Closed
ruixingw opened this Issue Apr 12, 2017 · 6 comments

Comments

Projects
None yet
5 participants
@ruixingw

ruixingw commented Apr 12, 2017

Creators Update (15063.138)
A fresh new WSL by:

lxrun.exe /uninstall /full
lxrun.exe /install

Now in WSL:
sudo apt-get update
sudo apt-get install zsh
Go to ZSH by "%SYSTEMROOT%\System32\bash.exe" -c zsh (I use ConEmu)

Put any command to background with &. It seems that the command is properly executed, but an annoying error message also shows.

Surface-SP4% echo "test" > test
Surface-SP4% echo "test" > test &
[1] 611
Surface-SP4% zsh: nice(5) failed: operation not permitted
[1] + done echo "test" > test
Surface-SP4% echo "test" > test &!
Surface-SP4% zsh: nice(5) failed: operation not permitted

Surface-SP4% ping -c 3 8.8.8.8 &
Surface-SP4% zsh: nice(5) failed: operation not permitted
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=19.6 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=46 time=24.2 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=46 time=17.5 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 17.532/20.459/24.204/2.789 ms
[1] + done ping -c 3 8.8.8.8

Other post had also reported this problem for specific programs, but I found the problem is actually generic for any command.

Autojump: wting/autojump#474
I further looked into the "autojump_chpwd" function, and it also used "&" to put command to background.
z: Kerren/z@b04976c
z also uses "&" and has the same problem. This commit just use > /dev/null to ignore the error message

Both of the two issues are on WSL too.

I used WSL+ZSH in 14393 anniversary update as well, and it worked well without any problem. Hence I don't think this is an issue of ZSH, but perhaps WSL itself has changed something afterward.
EDIT: wting/autojump#474 said the following:

But I installed WSL ~a month ago and had insider slow ring. I had another laptop which was running WSL bash for ~half a year with insider fast ring, and I never experienced that issue there ... - weird

  • Expected results
    No error message.
  • Actual results (with terminal output if applicable)
    zsh: nice(5) failed: operation not permitted
  • Your Windows build number
    Creators Update(15063.138),
  • Steps / All commands required to reproduce the error from a brand new installation

sudo apt-get update
sudo apt-get install zsh
zsh
echo "test" > test &
ping -3 8.8.8.8 &

@ruixingw ruixingw changed the title from Error message with ZSH and use of "&" on Creators Update to Error message with ZSH and use of "&" in Creators Update Apr 12, 2017

ruixingw referenced this issue in Kerren/z Apr 12, 2017

Removed the error that outputs on Windows 10 Bash:
_z_precmd:1: nice(5) failed: operation not permitted

It's not a fatal error so I'm outputting it to null so that the user doesn't see it.
@Kerren

This comment has been minimized.

Show comment
Hide comment
@Kerren

Kerren Apr 15, 2017

Hey guys, since everything still works even when this operation fails, I just output it to null. This is linked to the previous commit mentioned above.

Kerren commented Apr 15, 2017

Hey guys, since everything still works even when this operation fails, I just output it to null. This is linked to the previous commit mentioned above.

@daiconrad

This comment has been minimized.

Show comment
Hide comment
@daiconrad

daiconrad Apr 15, 2017

Based on the message I presume zsh is trying to set the priority of the background process with nice.

It looks like nice doesn't work on BoW:

$ nice -n 10 echo
nice: cannot set niceness: Permission denied

I've attached strace.txt of:

strace -ff nice -n 10 echo

It looks like the culprit is:

getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, 10)        = -1 EACCES (Permission denied)

Searching, it looks like issue #1838 is open for that. This issue can be marked a duplicate of that one.

daiconrad commented Apr 15, 2017

Based on the message I presume zsh is trying to set the priority of the background process with nice.

It looks like nice doesn't work on BoW:

$ nice -n 10 echo
nice: cannot set niceness: Permission denied

I've attached strace.txt of:

strace -ff nice -n 10 echo

It looks like the culprit is:

getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, 10)        = -1 EACCES (Permission denied)

Searching, it looks like issue #1838 is open for that. This issue can be marked a duplicate of that one.

@daiconrad

This comment has been minimized.

Show comment
Hide comment
@daiconrad

daiconrad Apr 15, 2017

There is a workaround. Tell zsh not to nice background processes. @ruixingw @Kerren

Add the following line to your .zshrc

unsetopt BG_NICE

See the zsh documentation for more details.

daiconrad commented Apr 15, 2017

There is a workaround. Tell zsh not to nice background processes. @ruixingw @Kerren

Add the following line to your .zshrc

unsetopt BG_NICE

See the zsh documentation for more details.

@ruixingw

This comment has been minimized.

Show comment
Hide comment
@ruixingw

ruixingw Apr 15, 2017

Thank you @daiconrad , the workaround works well.

Close this issue and let's wait for #1838 .

ruixingw commented Apr 15, 2017

Thank you @daiconrad , the workaround works well.

Close this issue and let's wait for #1838 .

@simnalamburt

This comment has been minimized.

Show comment
Hide comment
@simnalamburt

simnalamburt May 5, 2017

If you're going to use zplug, add unsetopt BG_NICE to ~/.zshenv rather than ~/.zshrc.

simnalamburt commented May 5, 2017

If you're going to use zplug, add unsetopt BG_NICE to ~/.zshenv rather than ~/.zshrc.

@tadasmajeris

This comment has been minimized.

Show comment
Hide comment
@tadasmajeris

tadasmajeris commented May 11, 2017

Thank you!

TobiX added a commit to TobiX/dotfiles that referenced this issue Nov 14, 2017

kodemeister added a commit to kodemeister/prezto that referenced this issue Dec 17, 2017

Mellbourn added a commit to Mellbourn/dotfiles that referenced this issue Feb 15, 2018

kodemeister added a commit to kodemeister/prezto that referenced this issue Sep 20, 2018

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