bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pty.h replacement


From: Bruno Haible
Subject: Re: pty.h replacement
Date: Tue, 8 Dec 2009 01:01:52 +0100
User-agent: KMail/1.9.9

Hi Simon,

> > Darwin has forkpty in util.h instead of the glibc name of pty.h.  I'm
> > working on a gnulib module to provide compatibility mappings... stay
> > tuned.
> 
> Here it is.  Tested on glibc debian and Mac OS X 10.5.

As far as I can see the portability situation of openpty and forkpty is like 
this:

Platform              Header              Library

Cygwin                <pty.h>             libc
Interix               <pty.h>             libc
OSF/1 4 and 5         <pty.h>             libc
glibc                 <pty.h>             libutil
MacOS X               <util.h>            libc
OpenBSD, NetBSD       <util.h>            libutil
FreeBSD               <libutil.h>         libutil

HP has a 10-page document "Implementing openpty and forkpty on HP-UX" [1].
See also [2].

[1] http://h30097.www3.hp.com/docs/transition/openpty.pdf
[2] http://forums.sun.com/thread.jspa?threadID=5084907

> +2009-12-07  Simon Josefsson  <address@hidden>
> +
> +     * modules/pty: New file.
> +     * modules/pty-tests: New file.
> +     * doc/glibc-headers/pty.texi: New file.

Your patch modifies pty.texi; it doesn't create it.

> diff --git a/doc/glibc-headers/pty.texi b/doc/glibc-headers/pty.texi
> index 26d7764..ec0d7fa 100644
> --- a/doc/glibc-headers/pty.texi
> +++ b/doc/glibc-headers/pty.texi

Actually, since openpty and forkpty are glibc function, therefore two files
  doc/glibc-functions/openpty.texi
  doc/glibc-functions/forkpty.texi
should be created. They escaped me when I created the hundreds of *.texi files.

>  Portability problems fixed by Gnulib:
>  @itemize
> address@hidden
> +This header file is missing on Mac OS X where the functions are
> +declared by util.h instead, and there is no requirement to link with
> address@hidden
>  @end itemize

Should also mention the other platforms (FreeBSD, NetBSD, OpenBSD).

> --- /dev/null
> +++ b/m4/pty.m4
> @@ -0,0 +1,29 @@
> +# pty.m4 serial 1
> +dnl Copyright (C) 2009 Free Software Foundation, Inc.
> +dnl This file is free software; the Free Software Foundation
> +dnl gives unlimited permission to copy and/or distribute it,
> +dnl with or without modifications, as long as this notice is preserved.
> +
> +# gl_PTY
> +# --------------------

20 dashes to underline 6 characters?

> +# Test whether forkpty is provided by pty.h and -lutil.  When forkpty
> +# is declared by util.h and available without -lutil instead (as it is
> +# on Mac OS X), provide a pty.h replacement.  Always define $(PTY_LIB)
> +# to the library.
> +AC_DEFUN([gl_PTY],
> +[
> +  PTY_H=''
> +  PTY_LIB='-lutil'
> +  AC_CHECK_HEADERS_ONCE([pty.h])
> +  if test $ac_cv_header_pty_h != yes; then

This code assumes that if <pty.h> exists, -lutil is needed, and vice
versa. But actually the issue of the header file and the issue of the
library are independent (see the table above).

Also there is the case of <libutil.h> instead of <util.h> (FreeBSD).

> +# We need the following in order to create <pty.h> when the system
> +# doesn't have one that works with the given compiler.
> +pty.h:
> +     echo '#include <util.h>' > address@hidden && \
> +     mv address@hidden $@

By convention, we put a line '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'
at the beginning of every autogenerated .h file. That was the outcome of a
discussion: people should be warned when attempting to edit such a file.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]