]> xenbits.xensource.com Git - people/dstodden/blktap.git/commitdiff
blktap2: Make tap-ctl spawn ouput the bare pid through pipes.
authorDaniel Stodden <daniel.stodden@citrix.com>
Tue, 29 Jun 2010 20:03:09 +0000 (13:03 -0700)
committerDaniel Stodden <daniel.stodden@citrix.com>
Tue, 29 Jun 2010 20:03:09 +0000 (13:03 -0700)
control/tap-ctl.c

index fe3c672419adc27152d37fb589db34469d60d685..619dc4f8b1be242aec2629e80bf0f657b0b30509 100644 (file)
@@ -340,8 +340,8 @@ tap_cli_spawn_usage(FILE *stream)
 static int
 tap_cli_spawn(int argc, char **argv)
 {
-       int c;
-       pid_t task;
+       int c, tty;
+       pid_t pid;
 
        optind = 0;
        while ((c = getopt(argc, argv, "h")) != -1) {
@@ -354,13 +354,16 @@ tap_cli_spawn(int argc, char **argv)
                }
        }
 
-       task = tap_ctl_spawn();
-       if (task < 0) {
-               printf("spawn failed: %d\n", errno);
-               return task;
-       }
+       pid = tap_ctl_spawn();
+       if (pid < 0)
+               return pid;
+
+       tty = isatty(STDOUT_FILENO);
+       if (tty)
+               printf("tapdisk spawned with pid %d\n", pid);
+       else
+               printf("%d\n", pid);
 
-       printf("tapdisk spawned with pid %d\n", task);
        return 0;
 
 usage: