]> sourceware.org Git - lvm2.git/commitdiff
TEST: When INTERACTIVE=1, allow scripts to control a TTY.
authorPetr Rockai <prockai@redhat.com>
Mon, 8 Oct 2012 18:15:55 +0000 (20:15 +0200)
committerPetr Rockai <prockai@redhat.com>
Mon, 8 Oct 2012 18:35:29 +0000 (20:35 +0200)
test/lib/harness.c

index c1d6774e5d00f3f8ba7407649c76ca2dd787ca78..929bfc8b776d43d64793d3812b9310ca6f436428 100644 (file)
@@ -44,6 +44,7 @@ static int readbuf_sz = 0, readbuf_used = 0;
 
 static int die = 0;
 static int verbose = 0; /* >1 with timestamps */
+static int interactive = 0; /* disable all redirections */
 
 struct subst {
        const char *key;
@@ -278,11 +279,13 @@ static void run(int i, char *f) {
                perror("Fork failed.");
                exit(201);
        } else if (pid == 0) {
-               close(0);
-               dup2(fds[0], 1);
-               dup2(fds[0], 2);
-               close(fds[0]);
-               close(fds[1]);
+               if (!interactive) {
+                       close(0);
+                       dup2(fds[0], 1);
+                       dup2(fds[0], 2);
+                       close(fds[0]);
+                       close(fds[1]);
+               }
                execlp("bash", "bash", f, NULL);
                perror("execlp");
                fflush(stderr);
@@ -320,7 +323,8 @@ static void run(int i, char *f) {
 }
 
 int main(int argc, char **argv) {
-       const char *be_verbose = getenv("VERBOSE");
+       const char *be_verbose = getenv("VERBOSE"),
+                  *be_interactive = getenv("INTERACTIVE");
        time_t start = time(NULL);
        int i;
 
@@ -332,6 +336,9 @@ int main(int argc, char **argv) {
        if (be_verbose)
                verbose = atoi(be_verbose);
 
+       if (be_interactive)
+               interactive = atoi(be_interactive);
+
        if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds)) {
                perror("socketpair");
                return 201;
This page took 0.036186 seconds and 5 git commands to generate.