1 From 3c4b5a852d5bb9070c7fb4428aa50f2e3e1f6e1b Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
3 Date: Thu, 19 Sep 2013 11:25:49 +0200
4 Subject: [PATCH] Confirm success for each tc -batch command
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 If `tc -force -batch' is fed by a controlling program from a pipe,
10 it's not possible to recognize when a command has been processes
13 This patch adds an optional `-OK' option to the tc(8) tool, so `tc
14 -force -OK -batch' will print "OK\n" to standard output on each
15 successfully completed tc command.
17 Signed-off-by: Petr Písař <ppisar@redhat.com>
19 man/man8/tc.8 | 8 +++++++-
21 2 files changed, 14 insertions(+), 2 deletions(-)
23 diff --git a/man/man8/tc.8 b/man/man8/tc.8
24 index e0acfeb..583eae2 100644
31 -.B tc [ -force ] -b\fR[\fIatch\fR] \fB[ filename ]
32 +.B tc [ -force ] [ -OK ] -b\fR[\fIatch\fR] \fB[ filename ]
36 @@ -440,6 +440,12 @@ First failure will cause termination of tc.
37 don't terminate tc on errors in batch mode.
38 If there were any errors during execution of the commands, the application return code will be non zero.
44 +and a new line on standard output after each successfully interpreted command.
48 was written by Alexey N. Kuznetsov and added in Linux 2.2.
49 diff --git a/tc/tc.c b/tc/tc.c
50 index 9b50e74..b43bb47 100644
53 @@ -39,6 +39,7 @@ int batch_mode = 0;
54 int resolve_hosts = 0;
58 struct rtnl_handle rth;
60 static void *BODY = NULL; /* cached handle dlopen(NULL) */
61 @@ -183,7 +184,7 @@ noexist:
62 static void usage(void)
64 fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
65 - " tc [-force] -batch filename\n"
66 + " tc [-force] [-OK] -batch filename\n"
67 "where OBJECT := { qdisc | class | filter | action | monitor }\n"
68 " OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] }\n");
70 @@ -251,6 +252,9 @@ static int batch(const char *name)
80 @@ -288,6 +292,8 @@ int main(int argc, char **argv)
82 } else if (matches(argv[1], "-force") == 0) {
84 + } else if (matches(argv[1], "-OK") == 0) {
86 } else if (matches(argv[1], "-batch") == 0) {