+
+/* COMPAT: SYSV version defaults size (and has a max value of) to 470.
+ We try to make it as large as possible. */
+#if !defined(ARG_MAX) && defined(_SC_ARG_MAX)
+#define ARG_MAX sysconf (_SC_ARG_MAX)
+#endif
+#ifndef ARG_MAX
+#define ARG_MAX 470
+#endif
+
+
+#ifdef TEST
+# ifndef ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION
+# define ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION 1
+# endif
+# ifndef ENABLE_FEATURE_XARGS_SUPPORT_QUOTES
+# define ENABLE_FEATURE_XARGS_SUPPORT_QUOTES 1
+# endif
+# ifndef ENABLE_FEATURE_XARGS_SUPPORT_TERMOPT
+# define ENABLE_FEATURE_XARGS_SUPPORT_TERMOPT 1
+# endif
+# ifndef ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
+# define ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 1
+# endif
+#endif
+
+/*
+ This function has special algorithm.
+ Don't use fork and include to main!
+*/
+static int xargs_exec(char **args)
+{
+ int status;
+
+ status = spawn_and_wait(args);
+ if (status < 0) {
+ bb_simple_perror_msg(args[0]);
+ return errno == ENOENT ? 127 : 126;
+ }
+ if (status == 255) {
+ bb_error_msg("%s: exited with status 255; aborting", args[0]);
+ return 124;
+ }
+/* Huh? I think we won't see this, ever. We don't wait with WUNTRACED!
+ if (WIFSTOPPED(status)) {
+ bb_error_msg("%s: stopped by signal %d",
+ args[0], WSTOPSIG(status));
+ return 125;
+ }
+*/
+ if (status >= 1000) {
+ bb_error_msg("%s: terminated by signal %d",
+ args[0], status - 1000);
+ return 125;
+ }
+ if (status)
+ return 123;
+ return 0;
+}
+
+
+typedef struct xlist_t {
+ struct xlist_t *link;
+ size_t length;
+ char xstr[1];
+} xlist_t;
+
+static smallint eof_stdin_detected;
+
+#define ISBLANK(c) ((c) == ' ' || (c) == '\t')
+#define ISSPACE(c) (ISBLANK(c) || (c) == '\n' || (c) == '\r' \
+ || (c) == '\f' || (c) == '\v')
+
+#if ENABLE_FEATURE_XARGS_SUPPORT_QUOTES
+static xlist_t *process_stdin(xlist_t *list_arg,
+ const char *eof_str, size_t mc, char *buf)