Re: [dev] [st][PATCH v2] Add tty line support
> > + if (opt_line) {
> > + if((cmdfd = open(opt_line, O_RDWR)) < 0)
> > + die("open line failed: %s\n", strerror(errno));
> > + close(STDIN_FILENO);
> > + dup(cmdfd);
> > + stty();
> > + return;
> Is the duplication of the cmdfd without saving the duplicated file
> descriptor intentional?
dup(2):
The dup() system call creates a copy of the file descriptor oldfd,
using the lowest-numbered unused descriptor for the new descriptor.
You can see that before dup, stdin is closed, so stdin is redirected
to cmdfd. -Wunused-result is not a good friend, and it is the
responsible of things like:
(void) printf(...);
This redirection is done because we need to execute:
stty args < /dev/ttyX
Instead, we can do something like:
stty -F /dev/ttyX args
but I don't want to do something like this because
with the current implementation stty() can be called
also in the case of creating a pseudo terminal, because
the slave has the correct stdin. I didn't add the stty
call directly to the slave part because it will slow down
st at the beginning and for the majority of the people
it will not be needed (maybe it is needed for the persons
with backspace as backspace).
Regards,
Received on Tue Apr 21 2015 - 19:20:30 CEST
This archive was generated by hypermail 2.3.0
: Tue Apr 21 2015 - 19:24:08 CEST