[Python-Dev] posixmodule.c diffs for working forkpty() and openpty() under Solaris 2.8

Lance Ellinghaus lellinghaus@yahoo.com
Sat, 29 Jun 2002 13:57:05 -0700 (PDT)


Martin:
See my comments below please...

--- "Martin v. Loewis" <martin@v.loewis.de> wrote:
> Lance Ellinghaus <lellinghaus@yahoo.com> writes:
> 
> > Please let me know if anyone has any problems with this!
> 
> I do. I have the general problem with posting such patches to
> python-dev; please put them onto SF instead. For specific problems,
> please see below.

I did not think just anyone could post to the python section on SF. My
mistake. The rest of the comments are below...

> > ! #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) ||
> defined(sun)
> > ! #ifdef sun
> > ! #include <sys/stropts.h>
> > ! #endif
> 
> I don't like #if <system> defines. What is the problem, and why can't
> it be solved with a HAVE_ test?

The problem is that Solaris (SUN) does NOT have openpty() and does not
have forkpty().. So what HAVE_ test would you suggest? What would I
test for? I guess I could have tested for "grantpt()", but testing for
"sun" works as needed. I understand your PERSONAL problem with testing
for SYSTEMs.. but that does not mean it is WRONG.. 

> Also, are you certain your changes apply to all systems that define
> sun?

Yes. All currently supported Solaris systems will need this patch to
provide openpty() and forkpty() services. Supported Solaris is 2.8.
This should work with 2.9 as well.

> > +         master_fd = open("/dev/ptmx", O_RDWR|O_NOCTTY);  /* open
> master */
> > +         sig_saved = signal(SIGCHLD, SIG_DFL);
> > +         grantpt(master_fd);                     /* change
> permission of   slave */
> > +         unlockpt(master_fd);                    /* unlock slave
> */
> > +         signal(SIGCHLD,sig_saved);
> > +         slave_name = ptsname(master_fd);         /* get name of
> slave */
> > +         slave_fd = open(slave_name, O_RDWR);    /* open slave */
> > +         ioctl(slave_fd, I_PUSH, "ptem");       /* push ptem */
> > +         ioctl(slave_fd, I_PUSH, "ldterm");     /* push ldterm*/
> > +         ioctl(slave_fd, I_PUSH, "ttcompat");     /* push
> ttcompat*/
> 
> Again, that is a fragment that seems to apply to more systems than
> just Solaris. It appears that atleast HP-UX has the same API, perhaps
> other SysV systems have that as well.

This may be the case. I was not coding for these other systems. I was
only coding for Sun Solaris 2.8. If someone wants to test it on those
other systems, then it could be expanded for them.

> On some of these other systems, ttcompat is not used, see
> 
>
http://ou800doc.caldera.com/SDK_sysprog/_Pseudo-tty_Drivers_em_ptm_and_p.html
> 

Again, was I coding for other systems? No. Hence the "#if
defined(sun)". Again, many other systems do not need this patch as they
already have forkpty() and openpty() defined.

> for an example. So I wonder whether it should be used by default -
> especially since the Solaris man page says that it can be autopushed
> as well.

Yes. You can use the autopush feature, but that requires making changes
to the OS level configuration files. If they have been autopushed, it
will not reload them. You do not want the requirement of making changes
to the OS level configuration files if you can keep from having to do
it. BTW: This is how SSH, EMACS, and other programs do it (YES I
LOOKED!).

Lance


=====
--
Lance Ellinghaus

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com