+static int noninteractive(int argc, char **argv) {
+ int retval = 0;
+ struct stat s;
+ fstat(fileno(stdin), &s);
+ if (S_ISFIFO(s.st_mode) || S_ISREG(s.st_mode)) { /* pipe, regular file */
+ argv = zrealloc(argv, (argc+1)*sizeof(char*));
+ argv[argc] = readArgFromStdin();
+ retval = cliSendCommand(argc+1, argv, config.repeat);
+ } else {
+ /* stdin is probably a tty, can be tested with S_ISCHR(s.st_mode) */
+ retval = cliSendCommand(argc, argv, config.repeat);
+ }
+ return retval;
+}
+