Use posix_openpt() for creating pseudo TTY pairs
Use posix_openpt() for creating pseudo TTY pairs, rather than depending on the presence of /dev/ptmx, which is not a portable assumption
This commit is contained in:
parent
854d3bc9a7
commit
8f3bcc3d41
2 changed files with 6 additions and 2 deletions
|
@ -51,7 +51,11 @@ int main(int argc, char **argv) {
|
|||
usage(argc, argv, "Too many arguments provided");
|
||||
}
|
||||
|
||||
if ((info.fd = open(argv[1], O_RDWR)) < 0) {
|
||||
info.fd = strcmp(argv[1], "/dev/ptmx") == 0?
|
||||
posix_openpt(O_RDWR | O_NOCTTY):
|
||||
open(argv[1], O_RDWR | O_NOCTTY);
|
||||
|
||||
if (info.fd < 0) {
|
||||
fprintf(stderr, "%s: %s: %s: %s\n",
|
||||
argv[0], "open()", argv[1], strerror(errno));
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ struct slot {
|
|||
static int bind_pty(patty_ax25_sock *sock) {
|
||||
char *pty;
|
||||
|
||||
if ((sock->fd = open("/dev/ptmx", O_RDWR)) < 0) {
|
||||
if ((sock->fd = posix_openpt(O_RDWR | O_NOCTTY)) < 0) {
|
||||
goto error_open;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue