version 1.8, 2009/06/27 12:57:14 |
version 1.9, 2009/07/07 17:24:32 |
|
|
tty_init(struct tty *tty, char *path, char *term) |
tty_init(struct tty *tty, char *path, char *term) |
{ |
{ |
tty->path = xstrdup(path); |
tty->path = xstrdup(path); |
if (term == NULL) |
if (term == NULL || *term == '\0') |
tty->termname = xstrdup("unknown"); |
tty->termname = xstrdup("unknown"); |
else |
else |
tty->termname = xstrdup(term); |
tty->termname = xstrdup(term); |
|
|
if ((mode = fcntl(tty->fd, F_GETFL)) == -1) |
if ((mode = fcntl(tty->fd, F_GETFL)) == -1) |
fatal("fcntl failed"); |
fatal("fcntl failed"); |
if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1) |
if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1) |
fatal("fcntl failedo"); |
fatal("fcntl failed"); |
if (fcntl(tty->fd, F_SETFD, FD_CLOEXEC) == -1) |
if (fcntl(tty->fd, F_SETFD, FD_CLOEXEC) == -1) |
fatal("fcntl failed"); |
fatal("fcntl failed"); |
|
|