bug-gnulib
[Top][All Lists]
Advanced

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

Re: portable openpty, forkpty


From: Bruno Haible
Subject: Re: portable openpty, forkpty
Date: Sun, 25 Apr 2010 13:00:22 +0200
User-agent: KMail/1.9.9

Hi Simon,

> The stand-alone program below reproduces the Mac OS X bug:
> 
> espresso:~ jas$ cc -Wall -o test-openpty test-openpty.c
> espresso:~ jas$ ./test-openpty master
> Closing master: 0
> espresso:~ jas$ ./test-openpty slave
> ^C
> espresso:~ jas$ ./test-openpty
> ^C^Z^C^Z^C^Z^C^Z

> Bruno, can you confirm that this program works fine on your 10.5
> machine?

Yes. After changing the 'argc >= 1' tests to 'argc >= 2', I see this
on MacOS X 10.5.6:

  $ ./test-openpty 
  $ echo $?
  0
  $ ./test-openpty master
  Closing master: 0
  $ echo $?
  0
  $ ./test-openpty slave 
  Closing slave: 0
  $ echo $?
  0

This is the same behaviour as on Linux. And I was using an ssh connection,
like you.

> This is on a fully updated Mac OS X 10.4.11 (PPC) PowerBook G4 laptop.
> If anyone else has access to an Intel 10.4.x Mac machine, it would be
> interesting to attempt to reproduce this.

I don't think such things depend on CPU type.

> diff --git a/doc/glibc-functions/openpty.texi 
> b/doc/glibc-functions/openpty.texi
> index 31fdca0..f345f7d 100644
> --- a/doc/glibc-functions/openpty.texi
> +++ b/doc/glibc-functions/openpty.texi
> @@ -30,4 +30,8 @@ Portability problems not fixed by Gnulib:
>  @item
>  This function is missing on some platforms:
>  mingw.
> address@hidden
> +On Mac OS X 10.4.11 (PowerPC) the application needs to close the
> +master file descriptor, otherwise the process hangs and is not
> +possible to kill.
>  @end itemize

I'm committing this, clarifying that the master file descriptor needs to be
closed before the slave file descriptor:


2010-04-25  Simon Josefsson  <address@hidden>
            Bruno Haible  <address@hidden>

        Work around a MacOS X 10.4 bug with openpty.
        * doc/glibc-functions/openpty.texi: Mention the MacOS X 10.4 bug.
        * tests/test-openpty.c (main): Close the master side explicitly.

--- doc/glibc-functions/openpty.texi.orig       Sun Apr 25 12:58:21 2010
+++ doc/glibc-functions/openpty.texi    Sun Apr 25 12:55:13 2010
@@ -30,4 +30,9 @@
 @item
 This function is missing on some platforms:
 mingw.
address@hidden
+After a successful call to @code{openpty}, the application needs to close
+the master's file descriptor before closing the slave's file descriptor,
+otherwise the process may hang in a state where it cannot be killed, on
+some platforms: MacOS X 10.4.11.
 @end itemize
--- tests/test-openpty.c.orig   Sun Apr 25 12:58:21 2010
+++ tests/test-openpty.c        Sun Apr 25 12:56:34 2010
@@ -99,6 +99,10 @@
           return 1;
         }
     }
+
+    /* Close the master side before the slave side gets closed.
+       This is necessary on MacOS X 10.4.11.  */
+    close (master);
   }
 
   return 0;




reply via email to

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