Adjust xexec() exit code to be 127, and tweaks for nommu friendliness.
authorRob Landley <rob@landley.net>
Thu, 6 Aug 2015 12:39:23 +0000 (07:39 -0500)
committerRob Landley <rob@landley.net>
Thu, 6 Aug 2015 12:39:23 +0000 (07:39 -0500)
lib/xwrap.c

index 54f2cbb..8086282 100644 (file)
@@ -30,10 +30,10 @@ void xstrncat(char *dest, char *src, size_t size)
 
 void xexit(void)
 {
+  if (toys.rebound) longjmp(*toys.rebound, 1);
   if (fflush(NULL) || ferror(stdout))
     if (!toys.exitval) perror_msg("write");
-  if (toys.rebound) longjmp(*toys.rebound, 1);
-  else exit(toys.exitval);
+  exit(toys.exitval);
 }
 
 // Die unless we can allocate memory.
@@ -136,7 +136,10 @@ void xexec(char **argv)
   if (CFG_TOYBOX && !CFG_TOYBOX_NORECURSE) toy_exec(argv);
   execvp(argv[0], argv);
 
-  perror_exit("exec %s", argv[0]);
+  perror_msg("exec %s", argv[0]);
+  toys.exitval = 127;
+  if (!CFG_TOYBOX_FORK) _exit(toys.exitval);
+  xexit();
 }
 
 // Spawn child process, capturing stdin/stdout.