subproc: save/restore errno when printing error message twice
This commit is contained in:
parent
46f463a62c
commit
8059747016
@ -4,14 +4,14 @@ package nsjail;
|
|||||||
|
|
||||||
enum Mode {
|
enum Mode {
|
||||||
LISTEN = 0; /* Listening on a TCP port */
|
LISTEN = 0; /* Listening on a TCP port */
|
||||||
ONCE = 1; /* Running the command once only */
|
ONCE = 1; /* Running the command once only */
|
||||||
RERUN = 2; /* Re-executing the command (forever) */
|
RERUN = 2; /* Re-executing the command (forever) */
|
||||||
EXECVE = 3; /* Executing command w/o the supervisor */
|
EXECVE = 3; /* Executing command w/o the supervisor */
|
||||||
}
|
}
|
||||||
/* Should be self explanatory */
|
/* Should be self explanatory */
|
||||||
enum LogLevel {
|
enum LogLevel {
|
||||||
DEBUG = 0; /* Equivalent to the '-v' cmd-line option */
|
DEBUG = 0; /* Equivalent to the '-v' cmd-line option */
|
||||||
INFO = 1; /* Default level */
|
INFO = 1; /* Default level */
|
||||||
WARNING = 2; /* Equivalent to the '-q' cmd-line option */
|
WARNING = 2; /* Equivalent to the '-q' cmd-line option */
|
||||||
ERROR = 3;
|
ERROR = 3;
|
||||||
FATAL = 4;
|
FATAL = 4;
|
||||||
|
@ -435,9 +435,11 @@ bool runChild(nsjconf_t* nsjconf, int fd_in, int fd_out, int fd_err) {
|
|||||||
close(child_fd);
|
close(child_fd);
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
if (flags & CLONE_NEWCGROUP) {
|
if (flags & CLONE_NEWCGROUP) {
|
||||||
|
auto saved_errno = errno;
|
||||||
PLOG_E(
|
PLOG_E(
|
||||||
"nsjail tried to use the CLONE_NEWCGROUP clone flag, which is "
|
"nsjail tried to use the CLONE_NEWCGROUP clone flag, which is "
|
||||||
"supported under kernel versions >= 4.6 only. Try disabling this flag");
|
"supported under kernel versions >= 4.6 only. Try disabling this flag");
|
||||||
|
errno = saved_errno;
|
||||||
}
|
}
|
||||||
PLOG_E(
|
PLOG_E(
|
||||||
"clone(flags=%s) failed. You probably need root privileges if your system "
|
"clone(flags=%s) failed. You probably need root privileges if your system "
|
||||||
|
Loading…
Reference in New Issue
Block a user