-.\" $OpenBSD: cu.1,v 1.14 2015/04/24 18:06:31 deraadt Exp $
+.\" $OpenBSD: cu.1,v 1.15 2015/05/18 09:35:05 nicm Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: April 24 2015 $
+.Dd $Mdocdate: May 18 2015 $
.Dt CU 1
.Os
.Sh NAME
.Nd serial terminal emulator
.Sh SYNOPSIS
.Nm
+.Op Fl d
.Op Fl l Ar line
.Op Fl s Ar speed | Fl Ar speed
.Nm
.Pp
The options are as follows:
.Bl -tag -width 4n
+.It Fl d
+Specify that the line is directly connected and
+.Nm
+should not allow the driver to block waiting for a carrier to be detected.
.It Fl l Ar line
Specify the line to use.
Either of the forms like
uses the
.Xr remote 5
database to retrieve the
+.Sy dc Pq directly connected ,
.Sy dv Pq device
and
.Sy br Pq baud rate
-/* $OpenBSD: cu.c,v 1.21 2015/02/08 17:33:35 nicm Exp $ */
+/* $OpenBSD: cu.c,v 1.22 2015/05/18 09:35:05 nicm Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
struct termios saved_tio;
struct bufferevent *input_ev;
struct bufferevent *output_ev;
+int is_direct = -1;
const char *line_path = NULL;
int line_speed = -1;
int line_fd;
__dead void
usage(void)
{
- fprintf(stderr, "usage: %s [-l line] [-s speed | -speed]\n",
+ fprintf(stderr, "usage: %s [-d] [-l line] [-s speed | -speed]\n",
__progname);
fprintf(stderr, " %s [host]\n", __progname);
exit(1);
{
const char *errstr;
char *tmp, *s, *host;
- int opt, i;
+ int opt, i, flags;
if (isatty(STDIN_FILENO) && tcgetattr(STDIN_FILENO, &saved_tio) != 0)
err(1, "tcgetattr");
errx(1, "speed asprintf");
}
- while ((opt = getopt(argc, argv, "l:s:")) != -1) {
+ while ((opt = getopt(argc, argv, "dl:s:")) != -1) {
switch (opt) {
+ case 'd':
+ is_direct = 1;
+ break;
case 'l':
line_path = optarg;
break;
if (argc != 0 && argc != 1)
usage();
- if (line_path != NULL || line_speed != -1) {
+ if (line_path != NULL || line_speed != -1 || is_direct != -1) {
if (argc != 0)
usage();
} else {
line_path = "/dev/cua00";
if (line_speed == -1)
line_speed = 9600;
+ if (is_direct == -1)
+ is_direct = 0;
if (strchr(line_path, '/') == NULL) {
if (asprintf(&tmp, "%s%s", _PATH_DEV, line_path) == -1)
line_path = tmp;
}
- line_fd = open(line_path, O_RDWR);
+ flags = O_RDWR;
+ if (is_direct)
+ flags |= O_NONBLOCK;
+ line_fd = open(line_path, flags);
if (line_fd < 0)
err(1, "open(\"%s\")", line_path);
if (ioctl(line_fd, TIOCEXCL) != 0)
}
}
+ if (is_direct == -1 && cgetcap(cp, "dc", ':') != NULL)
+ is_direct = 1;
+
if (line_path == NULL && cgetstr(cp, "dv", &s) >= 0)
line_path = s;