From 2c9fb90995c4e551d4f668f5a87309cea17c4f75 Mon Sep 17 00:00:00 2001
From: Dima Dorfman
Date: Sat, 24 Nov 2001 15:34:18 +0000
Subject: [PATCH] Return EBUSY if we try to attach to a tty that is already
being snooped on. This causes all kinds of Bad Things(tm) to happen since
closing one session will clobber state that's needed for the other one. This
could theoretically be supported if the code was careful, but until somebody
implements that, preventing this will stop people from unknowingly shooting
themselves in the foot.
---
sys/dev/snp/snp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
index e6cf7970e88..0b4504703d6 100644
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -508,6 +508,8 @@ snpioctl(dev, cmd, data, flags, td)
tp = snpdevtotty(tdev);
if (!tp)
return (EINVAL);
+ if (tp->t_state & TS_SNOOP)
+ return (EBUSY);
s = spltty();