open pty slave: Input/output error
What am I doing wrong?
Thanks,
Jeff
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#ifndef TIOCGPTN
#define TIOCGPTN _IOR('T',0x30, unsigned int)
#endif
#define die(x) { printf("%s: %s\n", x, strerror(errno)); exit(1); }
int
main (void)
{
int ptmx;
int pty_num;
char pty_name[32];
ptmx = open ("/dev/ptmx", O_RDWR);
if (ptmx < 0)
die ("open /dev/ptmx");
if (ioctl (ptmx, TIOCGPTN, &pty_num))
die ("ioctl TIOCGPTN /dev/ptmx");
snprintf (pty_name, sizeof (pty_name), "/dev/pts/%d", pty_num);
if (open (pty_name, O_RDWR) <0 ) die ("open pty slave");
return 0;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/