Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: binfmt fails on startup (Read 806 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

binfmt fails on startup

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.

Re: binfmt fails on startup

Reply #1
Actually, I'm going to cherry-pick this for s6-scripts as well. Thanks!

Edit: Merged here.