bug-gnulib
[Top][All Lists]
Advanced

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

Re: portable openpty, forkpty


From: Simon Josefsson
Subject: Re: portable openpty, forkpty
Date: Wed, 21 Apr 2010 21:24:51 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Simon Josefsson wrote:
>> HAVE_OPENPTY is not set in config.h though -- isn't that a bug?  The
>> system has openpty.
>> ...
>> Single stepping rpl_openpty:
>> 
>>   master = open ("/dev/ptmx", O_RDWR | O_NOCTTY);
>>   if (master < 0)
>> =>  return -1;
>> 
>> And indeed my Mac OS X system doesn't have /dev/ptmx:
>
> In the case the system does not have /dev/ptmx and has an openpty function,
> the safest approach is to use that functions - we don't know which device
> files it may try.
>
> But this works only if HAVE_OPENPTY is defined, and - you're right - the
> problem is that it does not get defined.
>
> This should fix it:

Now the test-openpty self-test hangs on my Mac OS X machine, and the
process doesn't even go away from the process table after a 'kill -9'.
Here is a gdb session, which suggests it hangs when shutting down the
process:

espresso:~/dummy-0/gltests jas$ gdb ./test-openpty
GNU gdb 6.3.50-20050815 (Apple version gdb-696) (Sat Oct 20 18:20:28 GMT 2007)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...
warning: --arch option not supported in this gdb.
Reading symbols for shared libraries .. done

(gdb) b main
Breakpoint 1 at 0x27e4: file test-openpty.c, line 42.
(gdb) r
Starting program: /Users/jas/dummy-0/gltests/test-openpty 
Reading symbols for shared libraries . done

Breakpoint 1, main () at test-openpty.c:42
42            int res = openpty (&master, &slave, NULL, NULL, NULL);
(gdb) n
43            if (res != 0)
(gdb) 
55            int tcfd = slave; /* You can try  tcfd = master;  here.  */
(gdb) 
58            if (tcgetattr (tcfd, &attributes) < 0)
(gdb) 
64            attributes.c_lflag |= ECHO | ICANON | ECHOE;
(gdb) 
65            attributes.c_cc[VERASE] = '\177';
(gdb) 
66            if (tcsetattr (tcfd, TCSANOW, &attributes) < 0)
(gdb) 
77            if (write (master, input, strlen (input)) < (int) strlen (input))
(gdb) 
87            int res = read (slave, buf, sizeof (buf));
(gdb) 
90            if (res < 0)
(gdb) 
95            if (!(res == strlen (expected)
(gdb) 
104       return 0;
(gdb) 
105     }
(gdb) 
0x000023e8 in _start ()
(gdb) 
Single stepping until exit from function _start, 
which has no line number information.

/Simon




reply via email to

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