lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / libbb / execable.c
index 5c7ac16a2c16465e99b1f9f3fc5f9b35e36709a0..d37640007791e431641c554172c0c96ef9c52384 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 2006 Gabriel Somlo <somlo at cmu.edu>
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 #include "libbb.h"
@@ -76,3 +76,11 @@ int FAST_FUNC bb_execvp(const char *file, char *const argv[])
                                        argv);
 }
 #endif
+
+int FAST_FUNC BB_EXECVP_or_die(char **argv)
+{
+       BB_EXECVP(argv[0], argv);
+       /* SUSv3-mandated exit codes */
+       xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
+}