+ // valid s must be of form: "SUBCMD | LEN | space | FNAME"
+ // N.B. we bail out on any error
+ s = xmalloc_read_stdin();
+ if (!s) { // (probably) EOF
+ char *p, *q, var[2];
+
+ // non-spooling mode or no spool helper specified
+ if (!spooling || !*argv)
+ return EXIT_SUCCESS; // the only non-error exit
+ // spooling mode but we didn't see both ctrlfile & datafile
+ if (spooling != 7)
+ goto err_exit; // reject job
+
+ // spooling mode and spool helper specified -> exec spool helper
+ // (we exit 127 if helper cannot be executed)
+ var[1] = '\0';
+ // read and delete ctrlfile
+ q = xmalloc_xopen_read_close(filenames[0], NULL);
+ unlink(filenames[0]);
+ // provide datafile name
+ // we can use leaky setenv since we are about to exec or exit
+ xsetenv("DATAFILE", filenames[1]);
+ // parse control file by "\n"
+ while ((p = strchr(q, '\n')) != NULL && isalpha(*q)) {
+ *p++ = '\0';
+ // q is a line of <SYM><VALUE>,
+ // we are setting environment string <SYM>=<VALUE>.
+ // Ignoring "l<datafile>", exporting others:
+ if (*q != 'l') {
+ var[0] = *q++;
+ xsetenv(var, q);
+ }
+ q = p; // next line
+ }
+ // helper should not talk over network.
+ // this call reopens stdio fds to "/dev/null"
+ // (no daemonization is done)
+ bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO | DAEMON_ONLY_SANITIZE, NULL);
+ BB_EXECVP(*argv, argv);
+ exit(127);
+ }
+
+ // validate input.