Error message with ZSH and use of "&" in Creators Update
ruixingw opened this issue · 6 comments
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 permittedSurface-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 &
- Strace of the failing command
https://pastebin.com/B25G4tWb
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.
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.
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.
Thank you @daiconrad , the workaround works well.
Close this issue and let's wait for #1838 .
If you're going to use zplug, add unsetopt BG_NICE
to ~/.zshenv
rather than ~/.zshrc
.
Thank you!