From 007d102d1d4c9260cf79a1ca612dfff0b682861e Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Fri, 10 May 2024 18:36:38 +0800 Subject: [PATCH] Allow netcat -f to communicate with serial devices Right now the (-f) option just opens the tty file and does nothing. Change it so that we actually read from / write to the specified file. --- toys/net/netcat.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/toys/net/netcat.c b/toys/net/netcat.c index 4e76fa7f..16cf40f0 100644 --- a/toys/net/netcat.c +++ b/toys/net/netcat.c @@ -104,8 +104,11 @@ void netcat_main(void) else if (FLAG(6)) family = AF_INET6; else if (FLAG(U)) family = AF_UNIX; - if (TT.f) in1 = out2 = xopen(TT.f, O_RDWR); - else { + if (TT.f) { + in1 = out2 = xopen(TT.f, O_RDWR); + alarm(0); + pollinate(in1, in2, out1, out2, TT.W, TT.q); + } else { // Setup socket if (!FLAG(l) && !FLAG(L)) { char *host = toys.optargs[0]; -- 2.39.2