amoffat / sh

Python process launching

Home Page:https://sh.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Exception] if /dev/fd not available

cocoon opened this issue · comments

The lines starting here:

sh/sh.py

Line 2068 in dd0318f

inherited_fds = os.listdir("/dev/fd")

cause an exception on systems where /dev/fd does not exists (a router in my case).

I just surrounded the block with "try".

Error Message:

    Traceback (most recent call last):
      File "/opt/lib/python3.9/site-packages/sh.py", line 2068, in __init__
        inherited_fds = os.listdir("/dev/fd")
    FileNotFoundError: [Errno 2] No such file or directory: '/dev/fd'

Thanks for the report!

Which kind of operating system is this, and which version? Does the system have another place it exposes file descriptors?

This is an ASUS RT-AX88U

and it looks like this:

admin@RT-AX88U:/tmp/home/root# ls /dev
2-2                 bcmvlan             fuse                mtd10               mtd9                pktrunner           ptypd               tty0                ttypf
ac97                bcmxtmcfg0          gmac                mtd10ro             mtd9ro              ppp                 ptype               tty1                ubi0
archer              bdmf_shell          i2c-0               mtd11               mtdblock0           printer0            ptypf               ttyH0               ubi0_0
autofs              blog                ingqos              mtd11ro             mtdblock1           ptm                 pwrmngt             ttyS0               ubi_ctrl
bcm                 bpm                 ivi                 mtd1ro              mtdblock10          ptmx                ram0                ttyp0               urandom
bcm_omci            brcmboard           kmem                mtd2                mtdblock11          pts                 random              ttyp1               usb1
bcm_ploam           btusb0              kmsg                mtd2ro              mtdblock2           ptyp0               rdpa_user           ttyp2               usb2
bcm_user_ploam      bus                 laser_dev           mtd3                mtdblock3           ptyp1               rgs_logger          ttyp3               usb3
bcm_user_tod        buzzz               log                 mtd3ro              mtdblock4           ptyp2               sda                 ttyp4               usb4
bcmadsl0            chipinfo            loop-control        mtd4                mtdblock5           ptyp3               sda1                ttyp5               wantypedetect
bcmadsl1            console             loop0               mtd4ro              mtdblock6           ptyp4               sda2                ttyp6               watchdog
bcmarl              cpu_dma_latency     loop1               mtd5                mtdblock7           ptyp5               sg0                 ttyp7               zero
bcmatm0             dect                loop2               mtd5ro              mtdblock8           ptyp6               shm                 ttyp8
bcmepon             dectdbg             loop3               mtd6                mtdblock9           ptyp7               slicslac            ttyp9
bcmfap              detector            mem                 mtd6ro              network_latency     ptyp8               sotp                ttypa
bcmomcipm           ext_bonding         memory_bandwidth    mtd7                network_throughput  ptyp9               spdsvc              ttypb
bcmprof             fbond               mtd0                mtd7ro              null                ptypa               sysperf             ttypc
bcmrdpa             fcache              mtd0ro              mtd8                opticaldetect       ptypb               tms                 ttypd
bcmtm               full                mtd1                mtd8ro              otp                 ptypc               tty                 ttype
admin@RT-AX88U:/tmp/home/root# ls /proc/self/fd
fd/      fdinfo/
admin@RT-AX88U:/tmp/home/root# ls /proc/self/fd
0  1  2  3

admin@RT-AX88U:/tmp/home/root# ls -al /proc/self/fd
dr-x------    2 admin    root             0 Dec  5 14:17 .
dr-xr-xr-x    7 admin    root             0 Dec  5 14:17 ..
lrwx------    1 admin    root            64 Dec  5 14:17 0 -> /dev/pts/2
lrwx------    1 admin    root            64 Dec  5 14:17 1 -> /dev/pts/2
lrwx------    1 admin    root            64 Dec  5 14:17 2 -> /dev/pts/2
ls: /proc/self/fd/3: cannot read link: No such file or directory
lr-x------    1 admin    root            64 Dec  5 14:17 3