diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-01-22 17:23:25 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-01-22 17:30:18 +0100 |
| commit | be6607c66e3414e3549d9568bb6840eee6f801be (patch) | |
| tree | 5f2b9b0b9d93992d882d6d8fe6294993cad7658f /src | |
| parent | 09855a7790d0a5a2eef4cbf6f60f84f2f9f8981e (diff) | |
| download | vyos-1x-be6607c66e3414e3549d9568bb6840eee6f801be.tar.gz vyos-1x-be6607c66e3414e3549d9568bb6840eee6f801be.zip | |
op-mode: T8154: fix tcpdump KeyboardInterrupt on Ctrl+C
Diffstat (limited to 'src')
| -rw-r--r-- | src/op_mode/tcpdump.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/op_mode/tcpdump.py b/src/op_mode/tcpdump.py index fcdb23a81..351b3d520 100644 --- a/src/op_mode/tcpdump.py +++ b/src/op_mode/tcpdump.py @@ -16,6 +16,7 @@ import sys +from vyos.utils.io import catch_broken_pipe from vyos.utils.process import call options = { @@ -51,8 +52,6 @@ options = { }, } -tcpdump = 'sudo /usr/bin/tcpdump' - class List(list): def first(self): return self.pop(0) if self else '' @@ -92,7 +91,8 @@ def complete(prefix): return [o for o in options if o.startswith(prefix)] -def convert(command, args): +def convert(args): + command = 'sudo /usr/bin/tcpdump' while args: shortname = args.first() longnames = complete(shortname) @@ -109,6 +109,9 @@ def convert(command, args): command=command, value=args.first()) return command +@catch_broken_pipe +def run_tcpdump(command: str, ifname: str) -> None: + call(f'{command} -i {ifname}') if __name__ == '__main__': args = List(sys.argv[1:]) @@ -161,5 +164,4 @@ if __name__ == '__main__': sys.stdout.write(helplines) sys.exit(0) - command = convert(tcpdump, args) - call(f'{command} -i {ifname}') + run_tcpdump(convert(args), ifname) |
