bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ENOEXEC from exec*() functions...?


From: Paul Smith
Subject: ENOEXEC from exec*() functions...?
Date: Mon, 30 Jul 2018 06:47:38 -0400

While looking into cleanups around fork/exec I ran into some confusing
code in GNU make.  This code dates back to the first version checked
into source control by Roland in 1992 (so who knows how far it really
goes back).

When an exec() fails, GNU make looks at the errno code and if the code
is ENOEXEC it retries the exec but this time giving the command to the
shell to run.  So for example if the command was:

  ./foo bar baz

it will attempt to rerun the exec() with:

  /bin/sh ./foo bar baz

I can't find a way to exercise this code path.

If the command being invoked doesn't have the executable bit set (e.g.,
I use "touch ./foo" with the above) then exec() fails with errno set to
EPERM not ENOEXEC, and if I make the script executable but without a #!
line at the top then exec() runs it in a shell without returning
ENOEXEC.

The GNU/Linux man page doesn't appear to allow this (a script that
doesn't start with #!) or at least doesn't document it as valid, but it
does work.  It lists ENOEXEC errno code as meaning:

  ENOEXEC
         An  executable  is  not in a recognized format, is for the wrong
         architecture, or has some other format error that means it  can‐
         not be executed.

Which doesn't sound like something that would be helped by re-running
as a shell script.  Maybe this is a feature of GNU/Linux and other
systems use ENOEXEC when there's no #! line?

Maybe some folks out there using less common systems know the answer to
that.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]