openSUSE / catatonit

A container init that is so simple it's effectively brain-dead.
GNU General Public License v2.0
188 stars 18 forks source link

Use environ instead of __environ #11

Closed erosennin closed 3 years ago

erosennin commented 3 years ago

Fixes compilation with musl.

catatonit currently fails to compile with musl because it uses the internal __environ variable which is not defined in musl's unistd.h:

catatonit.c: In function 'spawn_pid1':
catatonit.c:216:22: error: '__environ' undeclared (first use in this function); did you mean 'environ'?
  216 |  execvpe(file, argv, __environ);
      |                      ^~~~~~~~~
      |                      environ

This variable is also not mentioned in the glibc's documentation and should probably not be used. Changed it to the documented environ variable, which is also supported by musl with _GNU_SOURCE. With this PR, catatonit compiles successfully with both glibc and musl.

cyphar commented 3 years ago

LGTM. I have no idea why I used __environ.