From 476a946bfa65de9b5d07d1b4b661365b9b0718f7 Mon Sep 17 00:00:00 2001 From: Daniel Stodden Date: Tue, 29 Jun 2010 13:03:09 -0700 Subject: [PATCH] blktap2: Make tap-ctl spawn ouput the bare pid through pipes. --- control/tap-ctl.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/control/tap-ctl.c b/control/tap-ctl.c index fe3c672..619dc4f 100644 --- a/control/tap-ctl.c +++ b/control/tap-ctl.c @@ -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: -- 2.39.5