From 27ded4832d7a1b93d287ea9b968bf069d3628a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20B=C3=A4uerle?= Date: Mon, 24 Nov 2014 11:29:34 +0100 Subject: [PATCH] fastboot: add parameter for unbuffered stderr/stdout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is useful for writing Windows GUIs that want to parse the output of fastboot before it exits. Change-Id: Ic0171fe379fc4db7b65b1501e5f2e771ac7c62c4 Signed-off-by: Florian Bäuerle --- fastboot/fastboot.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c index 43d05aa3e..13425e68a 100644 --- a/fastboot/fastboot.c +++ b/fastboot/fastboot.c @@ -988,6 +988,7 @@ int main(int argc, char **argv) unsigned sz; int status; int c; + int longindex; const struct option longopts[] = { {"base", required_argument, 0, 'b'}, @@ -996,13 +997,14 @@ int main(int argc, char **argv) {"ramdisk_offset", required_argument, 0, 'r'}, {"tags_offset", required_argument, 0, 't'}, {"help", 0, 0, 'h'}, + {"unbuffered", 0, 0, 0}, {0, 0, 0, 0} }; serial = getenv("ANDROID_SERIAL"); while (1) { - c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:h", longopts, NULL); + c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:h", longopts, &longindex); if (c < 0) { break; } @@ -1063,6 +1065,12 @@ int main(int argc, char **argv) break; case '?': return 1; + case 0: + if (strcmp("unbuffered", longopts[longindex].name) == 0) { + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + } + break; default: abort(); }