Hi,
Today while trying to connect to my ERL via serial with cu(1) instead of cuaU0
I used usb0 (yes, I keep forgetting the correct one). But this is actually the
first time I typed it wrong and ran cu(1) with it and strangely enough saw it
being aborted by pledge saying that ioctl(TIOCEXCL) was not allowed.
Since with the correct device it works I checked pledge and the chunck below
means that the break will make pledge_ioctl return with errno EPERM complaining
about pledge, whereas perhaps it should return ENOTTY instead? This way it will
say that ioctl(TIOCEXCL) is not an appropriate ioctl for the device used.
Comments? Is there a better way to handle a non-TTY in this situation? Change
cu(1) to check if it's a TTY or not prior to invoke the ioctl?
Index: kern_pledge.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_pledge.c,v
retrieving revision 1.218
diff -u -p -u -r1.218 kern_pledge.c
--- kern_pledge.c 21 Aug 2017 14:40:07 -0000 1.218
+++ kern_pledge.c 22 Aug 2017 15:35:13 -0000
@@ -1298,7 +1298,7 @@ pledge_ioctl(struct proc *p, long com, s
case TIOCSCTTY: /* forkpty(3), login_tty(3), ... */
if (fp->f_type == DTYPE_VNODE && (vp->v_flag & VISTTY))
return (0);
- break;
+ return (ENOTTY);
}
}