Artix Linux Forum

Artix Linux => System => Topic started by: castilma on 08 March 2020, 12:23:17

Title: binfmt fails on startup
Post by: castilma on 08 March 2020, 12:23:17
Hey, I'm using runit and today I saw binfmt fail on startup.
The error is something like printf: write error: Invalid Argument.

I think I found the problem.
Code: [Select]
#part of /etc/rc/sysinit/95-binfmt
for path in /usr/lib/binfmt.d /etc/binfmt.d /run/binfmt.d; do
        [[ ! -d $path ]] && continue
        [[ -z "$(ls $path)" ]] && continue
        grep "^:" $path/* | \
            while read -r line; do
                printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register || retu>
            done
    done

The problem is the grep; if   $path/* expands to more than one file, grep automatically prefixes each line with the filename, which leads to an invalid argument for /proc/sys/fs/binfmt_misc/register.
Yesterday I installed wine and now have 2 files in /usr/lib/binfmt.d.

The fix is to call grep with -h:
Code: [Select]
grep -h "^:" $path/*

Edit: made a pr (https://github.com/artix-linux/runit-rc/pull/4).
Title: Re: binfmt fails on startup
Post by: Dudemanguy on 09 March 2020, 02:16:54
Actually, I'm going to cherry-pick this for s6-scripts as well. Thanks!

Edit: Merged here (https://gitea.artixlinux.org/artix/s6-scripts/commit/2c4224f5eadc7c61c9cf3cacda9dc5fa141c6ff6).