Files
runc/libcontainer/dmz/_dmz.c
T
Rodrigo Campos 8afeccc827 libct/dmz: Print execve() errors
This error code is using functions that are present in nolibc too.

When using nolibc, the error is printed like:

	exec /runc.armel: errno=8

When using libc, as its perror() implementation translates the errno to
a message, it is printed like:

	exec /runc.armel: exec format error

Note that when using libc, the error is printed in the same way as
before.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-01-21 15:35:46 +01:00

28 lines
574 B
C

#ifdef RUNC_USE_STDLIB
# include <linux/limits.h>
# include <stdio.h>
# include <string.h>
# include <unistd.h>
#else
# include "xstat.h"
# include "nolibc/nolibc.h"
#endif
extern char **environ;
int main(int argc, char **argv)
{
if (argc < 1)
return 127;
int ret = execve(argv[0], argv, environ);
if (ret) {
/* NOTE: This error message format MUST match Go's format. */
char err_msg[5 + PATH_MAX + 1] = "exec "; // "exec " + argv[0] + '\0'
strncat(err_msg, argv[0], PATH_MAX);
err_msg[sizeof(err_msg) - 1] = '\0';
perror(err_msg);
}
return ret;
}