This is the mail archive of the frysk@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Vte pty--it's baaaack


Chris Moller wrote:
The following works with no modification at all to vte other than the
vte-0.11.11 modification to the vte-0.11.10 patch I did a couple of
weeks ago:

      {
        int amaster;
        int aslave;
        char name[64];
        gboolean rc;
        int frc;

        openpty (&amaster, &aslave, name, NULL, NULL);
        fprintf (stderr, "m = %d, s = %d, n = \"%s\"\n", amaster,
    aslave, name);

        rc = vte_terminal_set_pty(VTE_TERMINAL (terminal), amaster);
        fprintf (stderr, "rc = %s\n", (TRUE == rc) ? "TRUE" : "FALSE");

        frc = fcntl (amaster, F_GETFL);
        fprintf (stderr, "master flags = %08o\n", frc);

        frc = fcntl (aslave, F_GETFL);
        fprintf (stderr, "slave flags = %08o\n", frc);

    #define TSTRING "Does it work?\n"
        write (amaster, TSTRING, strlen (TSTRING));
        fsync (amaster);
      }

returning

    m = 4, s = 5, n = "/dev/pts/2"
    rc = TRUE

and the test string shows up on the vte.  (I haven't tried reading--I'll
just assume it works, haha.)

Nice, much simpler.

One technical question, if the code goes on to open things using NAME and ignore ASLAVE, will the ASLAVE file-descriptor need to be closed and if so when can it be closed? I expect the GUI code to just use NAME and create objects using that.
There are only two impediments to using this from Java:

    * Adding vte_terminal_set_pty() to the libvte-java wrappers.
    * Giving Java access to openpty().

My original thought was to incorporate the openpty() wrapper into the
vte wrapper patch, but, on second thought, that would be a bit of an
ad-hoc thing.  My current thought is to have the openpty() wrapper go
somewhere else in frysk.  Would that be possible?

Right, one way or another, openpty will need to be wrapped. I can see the options:

- like you suggest have the java wrappers directly call openpty, returning the vte object and the pty name (I can't see Java code doing anything other than the above so I don't see it as too much of a hack :-)

- add something to glib (lets see if any gnome hackers jump on this) so there's a "portable" interface available and export | use that

- add something like frysk-sys/frysk/sys/Pty.java and have our gui code use that (of course the Java wrapper and VTE code can't use that)

I think, immediately, the third option will be the most straight forward.
Anyway, my immediate plan is to add the vte_terminal_set_pty() wrapper
and dump out a patch for that, then upstream both that patch and the vte
patch itself.


openpty(), BTW, requires linking with -lutil

I noticed that :-)

Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]