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

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

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

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

ruixingw opened this issue Apr 12, 2017 · 6 comments

Comments

@ruixingw
Copy link

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-ortlepp/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 Error message with ZSH and use of "&" on Creators Update Error message with ZSH and use of "&" in Creators Update Apr 12, 2017
ruixingw referenced this issue in kerren-ortlepp/z Apr 12, 2017
_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-ortlepp
Copy link

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
Copy link

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
Copy link

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
Copy link
Author

Thank you @daiconrad , the workaround works well.

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

@simnalamburt
Copy link

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

@tadasmajeris
Copy link

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
kodemeister added a commit to kodemeister/prezto that referenced this issue Apr 19, 2019
kodemeister added a commit to kodemeister/prezto that referenced this issue Oct 4, 2020
kodemeister added a commit to kodemeister/prezto that referenced this issue Oct 4, 2021
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

5 participants