Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!labtam!hamster!iand From: iand@hamster.labtam.oz (Ian Donaldson) Newsgroups: comp.unix.questions Subject: Re: PTYs with V.4 Message-ID: <23@hamster.labtam.oz> Date: 30 Jan 91 03:18:18 GMT References: <*&8^4!*@uzi-9mm.fulcrum.bt.co.uk> Organization: Labtam Australia, Melbourne, Australia Lines: 33 igb@fulcrum.bt.co.uk (Ian G Batten) writes: >The call TIOCGETP then fails EINVAL. >Outline of the code: > p = open ("/dev/ptmx", 2); > cp = ptsname (p); grantpt(p); <---- add this > unlockpt (p); > t = open(cp, 2); if(t == -1) { <---- add this perror(cp); <---- add this exit(1); <---- add this } <---- add this > if ((ioctl (t, I_PUSH, "ptem") < 0) || > (ioctl (t, I_PUSH, "ldterm") < 0) || > (ioctl (t, I_PUSH, "ttcompat") < 0)) > fatalperror (f, "stream push", errno); > if (ioctl(t, TIOCGETP, (char*)&b) == -1) { > perror("ioctl (TIOCGETP)"); > adios(NULLCP, "ioctl failed (TIOCGETP)"); > } <== fails here The program may have worked depending on the previous permissions of the pty returned by ptsname(). On our system the mode before grantpt() is called was 666 and so the program succeeded. However, the mode may have been anything, causing the 2nd open to fail. For an example of streams-pty usage, look in the freely available X11R4 xterm sources. Ian D