Skip to content

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

Closed
@ruixingw

Description

@ruixingw

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 &

Activity

changed the title [-]Error message with ZSH and use of "&" on Creators Update[/-] [+]Error message with ZSH and use of "&" in Creators Update[/+] on Apr 12, 2017
kerren-ortlepp

kerren-ortlepp commented on Apr 15, 2017

@kerren-ortlepp

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

daiconrad commented on Apr 15, 2017

@daiconrad

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

daiconrad commented on Apr 15, 2017

@daiconrad

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

ruixingw commented on Apr 15, 2017

@ruixingw
Author

Thank you @daiconrad , the workaround works well.

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

simnalamburt

simnalamburt commented on May 5, 2017

@simnalamburt

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

tadasmajeris

tadasmajeris commented on May 11, 2017

@tadasmajeris

Thank you!

added a commit that references this issue on Nov 14, 2017

10 remaining items

Loading
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

        Participants

        @daiconrad@kerren-ortlepp@simnalamburt@ruixingw@tadasmajeris

        Issue actions

          Error message with ZSH and use of "&" in Creators Update · Issue #1887 · microsoft/WSL