Skip to content

"setpgid: Permission denied" #4715

Closed
Closed

Description

@zx8

Following on from Gitter, I've attempted to reproduce this in a brand new environment. Seems related to virtualfish in some way?

$ fish --version
fish, version 2.7.1-764-g56a46a0b
$ uname -a
Darwin mac.local 15.6.0 Darwin Kernel Version 15.6.0: Tue Jan  9 20:12:05 PST 2018; root:xnu-3248.73.5~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,3 Darwin
$ sh -c 'env HOME=$(mktemp -d) fish'
Welcome to fish, the friendly interactive shell

zx8@mac ~> pip3 install virtualfish
Requirement already satisfied: virtualfish in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: virtualenv in /usr/local/lib/python3.6/site-packages (from virtualfish)

zx8@mac ~> set -g VIRTUALFISH_VERSION 1.0.5;set -g VIRTUALFISH_PYTHON_EXEC /usr/local/opt/python3/bin/python3.6;source /usr/local/lib/python3.6/site-packages/virtualfish/virtual.fish;emit virtualfish_did_setup_plugins

zx8@mac ~> vf tmp
The directory /var/folders/_0/wrr145xs4nj6b_8lncqmp9mm0000gn/T/tmp.4I6bqcGC1r/.virtualenvs does not exist.
Would you like to create it?
Tip: To use a different directory, set the variable $VIRTUALFISH_HOME.
y/n> y

Using base prefix '/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6'
New python executable in /var/folders/_0/wrr145xs4nj6b_8lncqmp9mm0000gn/T/tmp.4I6bqcGC1r/.virtualenvs/tempenv-70f1258906e37/bin/python3.6
Also creating executable in /var/folders/_0/wrr145xs4nj6b_8lncqmp9mm0000gn/T/tmp.4I6bqcGC1r/.virtualenvs/tempenv-70f1258906e37/bin/python
Installing setuptools, pip, wheel...done.

zx8@mac ~> vf activate tempenv-70f1258906e37
setpgid: Permission denied
Removing temporary virtualenv tempenv-70f1258906e37

setpgid: Permission denied

Activity

  1. changed the title [-]Error when changing directories: "setpgid: Permission denied"[/-] [+]"setpgid: Permission denied"[/+] on Feb 8, 2018
  2. zanchey commented on Feb 9, 2018

    @zanchey
    Member

    This is almost certainly due to the changes from #4676.

    The problem arises from:

    <2> fish: Fork #26, pid 93781: keepalive fork for 'functions -a | sed -n '/__vf_/{s///g;p;}''
    <2> fish: Fork #27, pid 93782: internal builtin for 'functions'
    <2> fish: Fork #28, pid 93783: spawn external command '/usr/bin/sed' from '-'
    setpgid: Permission denied
    
  3. zanchey commented on Feb 9, 2018

    @zanchey
    Member

    Minimal testcase:

    echo | sed &
    

    Sending to the background is required, otherwise the non-posix_spawn pathway is used.

  4. added
    bug
    on Feb 9, 2018
  5. added this to the milestone on Feb 9, 2018
  6. zanchey commented on Feb 13, 2018

    @zanchey
    Member

    I'm getting this a whole bunch on startup on current versions as well - @ridiculousfish, any thoughts?

  7. added a commit that references this issue on Feb 15, 2018
    be13ac3
  8. mqudsi commented on Feb 15, 2018

    @mqudsi
    Contributor

    This is because set_child_group() (now?) calls setpgid() unconditionally; processes executed via posix_spawn have their pgid set in the arguments to that call and don't need it. I fixed this in be13ac3 along with some other refactoring to hopefully make future job control work less error prone.

    Thanks for the simple testcase btw, made fixing this a lot easier!

  9. mqudsi commented on Mar 6, 2018

    @mqudsi
    Contributor

    I can see that @zx8 is on a mac from his host prompt; was it the same for you, @zanchey ?
    There's a chance this is more of a glibc bug than a WSL bug.

  10. zanchey commented on Mar 9, 2018

    @zanchey
    Member

    I could reproduce this on both Debian Linux and macOS.

  11. mqudsi commented on Mar 9, 2018

    @mqudsi
    Contributor

    There's a discussion going on at microsoft/WSL#2997 regarding what's really happening. There's a defect in glibc < 2.24 where posix_spawn almost never uses vfork() in real code (explaining why posix_spawn() was initially added to fish to boost performance on Mac in specific), which changes the synchronization semantics of the clone() call to use CLONE_VFORK.

    Ubuntu 16.04 LTS (which WSL uses by default) is still on GLIBC 2.23.

    @zanchey can you please check the glibc version your Debian is running?

    If it is indeed >= 2.24 then I should add a define based off of whether fork() or vfork() is used to conditionally call setpgid() only when/where needed. If not, more investigation is warranted.

    (Really good discussion on this topic: famzah/popen-noshell#11)

  12. zanchey commented on Mar 10, 2018

    @zanchey
    Member

    I can still reproduce this using glibc 2.24-11+deb9u1 and a build from 8cf476f.

  13. mqudsi commented on Mar 10, 2018

    @mqudsi
    Contributor

    Thanks, David. 🤷‍♀️

  14. added a commit that references this issue on May 17, 2018
    0dd2607
  15. reopened this on Jun 1, 2018
  16. mqudsi commented on Jun 1, 2018

    @mqudsi
    Contributor

    Seeing this (now?) under FreeBSD 12 with fish from master.

    We should be able to just silence the error message.

  17. locked as resolved and limited conversation to collaborators on Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions