Merge all the various definitions of the err variable

This commit is contained in:
madmaurice 2021-01-15 20:22:22 +01:00
parent b94fa5bfcf
commit 1ab32c39d0

10
main.c
View file

@ -62,6 +62,7 @@ char** argdup(int argc, const char** argv)
int main(int argc, const char** argv) int main(int argc, const char** argv)
{ {
int err;
if (argc == 1) if (argc == 1)
{ {
printf("Usage: pidjail PROGRAM ARGUMENTS...\n" printf("Usage: pidjail PROGRAM ARGUMENTS...\n"
@ -72,7 +73,7 @@ int main(int argc, const char** argv)
// next fork shall be in a new pid namespace // next fork shall be in a new pid namespace
if (unshare(CLONE_NEWPID) != 0) if (unshare(CLONE_NEWPID) != 0)
{ {
int err = errno; err = errno;
printf("Failed to unshare pid namespace (%d)\n", err); printf("Failed to unshare pid namespace (%d)\n", err);
return err; return err;
} }
@ -102,7 +103,7 @@ int main(int argc, const char** argv)
int status; int status;
if (waitpid(pid, &status, 0) == -1) if (waitpid(pid, &status, 0) == -1)
{ {
int err = errno; err = errno;
printf("Failed to wait (%d)\n", err); printf("Failed to wait (%d)\n", err);
return err; return err;
} }
@ -123,7 +124,6 @@ int main(int argc, const char** argv)
pid_t first_child = pid; pid_t first_child = pid;
pid_t exited_child; pid_t exited_child;
int child_status; int child_status;
int err;
// Setup forward for SIGTERM // Setup forward for SIGTERM
pid_child = first_child; pid_child = first_child;
@ -157,8 +157,8 @@ int main(int argc, const char** argv)
if (execvp(newargs[0], newargs) == -1) if (execvp(newargs[0], newargs) == -1)
{ {
printf("Failed to exec (%d)\n", errno); printf("Failed to exec (%d)\n", err);
return errno; return err;
} }
} }
} }