I sent this to gnats@ yesterday but got no response from it (is gnats
working?).  Sorry for the possible duplicate.


>Synopsis:      slattach over non-CLOCAL tty does not work
>Category:      bin
>Environment:
        System  : OpenBSD 5.0

>Description:
slattach does not work on local lines or pseudo-terminals.
This problem report is based on:
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=3586
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=45759

>How-To-Repeat:
Use slattach on a serial line with a 3-wire cable, or:

# ifconfig sl0 up
# slattach /dev/ptyp0
slattach: TIOCSDTR: Inappropriate ioctl for device

>Fix:
I propose the patch below, so that slattach can be used successfully on
pseudo-terminal or in 3-wire mode (command is: slattach -l /dev/ptyp0).

diff -rup orig/src/sbin/slattach/slattach.c new/src/sbin/slattach/slattach.c
--- orig/src/sbin/slattach/slattach.c   2009-10-29 05:32:40.000000000 +0100
+++ new/src/sbin/slattach/slattach.c    2011-12-30 14:22:42.000000000 +0100
@@ -80,11 +80,14 @@ main(int argc, char *argv[])
        sigset_t sigset;
        int i;
 
-       while ((ch = getopt(argc, argv, "hms:r:t:")) != -1) {
+       while ((ch = getopt(argc, argv, "hlms:r:t:")) != -1) {
                switch (ch) {
                case 'h':
                        cflag |= CRTSCTS;
                        break;
+               case 'l':
+                       cflag |= CLOCAL;
+                       break;
                case 'm':
                        cflag &= ~HUPCL;
                        break;
@@ -123,7 +126,7 @@ main(int argc, char *argv[])
        cfsetspeed(&tty, speed);
        if (tcsetattr(fd, TCSADRAIN, &tty) < 0)
                err(1, "tcsetattr");
-       if (ioctl(fd, TIOCSDTR, 0) < 0)
+       if (ioctl(fd, TIOCSDTR, 0) < 0 && errno != ENOTTY)
                err(1, "TIOCSDTR");
        if (ioctl(fd, TIOCSETD, &slipdisc) < 0)
                err(1, "TIOCSETD");
@@ -194,6 +197,6 @@ usage(void)
 {
 
        fprintf(stderr,
-           "usage: slattach [-t ldisc] [-hm] [-s baudrate] ttyname\n");
+           "usage: slattach [-t ldisc] [-hlm] [-s baudrate] ttyname\n");
        exit(1);
 }
diff -rup orig/src/sbin/slattach/slattach.8 new/src/sbin/slattach/slattach.8
--- orig/src/sbin/slattach/slattach.8   2008-06-10 01:01:22.000000000 +0200
+++ new/src/sbin/slattach/slattach.8    2011-12-30 14:27:15.000000000 +0100
@@ -60,6 +60,10 @@ The following operands are supported by
 .It Fl h
 Turn on RTS/CTS flow control.
 By default, no flow control is done.
+.It Fl l
+Turn on the CLOCAL flag, making it possible to run SLIP on a cable
+without modem control signals (e.g. DTR, DSR, DCD), or on a
+pseudo-terminal.
 .It Fl m
 Maintain modem control signals after closing the line.
 Specifically, this disables HUPCL.

Reply via email to