all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#12040: 24.1.50; `term' hangs on FreeBSD 10.0-CURRENT without pty(4)
@ 2012-07-23 11:31 Jan Beich
  2012-08-16  6:45 ` Glenn Morris
       [not found] ` <1T1tp3-000F13-AB@internal.tormail.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Beich @ 2012-07-23 11:31 UTC (permalink / raw)
  To: 12040

[-- Attachment #1: Type: text/plain, Size: 567 bytes --]

Starting with FreeBSD 8.0-RELEASE the system uses new tty layer that no
longer supports old style pseudo ttys *unless* pty(4) kernel module is
loaded. However, pty(4) device is still included in GENERIC kernel on
all releases except 10.0-CURRENT (removed in r233271).

  $ emacs -Q
  M-x term
  <hangs here>

  $ sudo kldload pty
  [try again]

A few ways to solve this:
- use openpty() in -lutil like darwin
- add use posix_openpt() support

http://svn.freebsd.org/changeset/base/233271
https://pub.allbsd.org/FreeBSD-snapshots/ # for testing, seems to be down atm


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: openpty.diff --]
[-- Type: text/x-patch, Size: 1233 bytes --]

=== modified file 'configure.ac'
--- configure.ac	2012-07-17 07:30:25 +0000
+++ configure.ac	2012-07-21 09:10:00 +0000
@@ -1220,7 +1220,7 @@
   linux/version.h sys/systeminfo.h
   stdio_ext.h fcntl.h coff.h pty.h
   sys/vlimit.h sys/resource.h
-  sys/utsname.h pwd.h utmp.h dirent.h util.h)
+  sys/utsname.h pwd.h utmp.h dirent.h util.h libutil.h)
 
 AC_MSG_CHECKING(if personality LINUX32 can be set)
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/personality.h>]], [[personality (PER_LINUX32)]])],
@@ -3344,7 +3344,7 @@
     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] )
     ;;
 
-  darwin )
+  darwin | freebsd )
     AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)] )
     dnl Not used, because PTY_ITERATION is defined.
     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
@@ -3356,7 +3356,7 @@
     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] )
     ;;
 
-  gnu | freebsd | netbsd | openbsd )
+  gnu | netbsd | openbsd )
     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
     ;;
 

=== modified file 'src/process.c'
--- src/process.c	2012-07-20 07:29:04 +0000
+++ src/process.c	2012-07-21 09:10:00 +0000
@@ -83,6 +83,10 @@
 #include <util.h>
 #endif
 
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
+
 #ifdef HAVE_PTY_H
 #include <pty.h>
 #endif


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: posix_openpt.diff --]
[-- Type: text/x-patch, Size: 1722 bytes --]

=== modified file 'configure.ac'
--- configure.ac	2012-07-17 07:30:25 +0000
+++ configure.ac	2012-07-23 10:52:48 +0000
@@ -2759,7 +2759,7 @@
 AC_CHECK_FUNCS(grantpt)
 
 # PTY-related GNU extensions.
-AC_CHECK_FUNCS(getpt)
+AC_CHECK_FUNCS(getpt posix_openpt)
 
 # Check this now, so that we will NOT find the above functions in ncurses.
 # That is because we have not set up to link ncurses in lib-src.
@@ -3356,11 +3356,11 @@
     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] )
     ;;
 
-  gnu | freebsd | netbsd | openbsd )
+  gnu | netbsd | openbsd )
     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
     ;;
 
-  gnu-linux | gnu-kfreebsd )
+  gnu-linux | gnu-kfreebsd | freebsd )
     dnl if HAVE_GRANTPT
     if test "x$ac_cv_func_grantpt" = xyes; then
       AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.])
@@ -3368,8 +3368,12 @@
       dnl Note that grantpt and unlockpt may fork.  We must block SIGCHLD
       dnl to prevent sigchld_handler from intercepting the child's death.
       AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname; sigblock (sigmask (SIGCHLD)); if (grantpt (fd) == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname(fd))) { sigunblock (sigmask (SIGCHLD)); close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); sigunblock (sigmask (SIGCHLD)); }] )
+      dnl if HAVE_POSIX_OPENPT
+      if test "x$ac_cv_func_posix_openpt" = xyes; then
+        AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_NOCTTY)])
+        AC_DEFINE(PTY_NAME_SPRINTF, [] )
       dnl if HAVE_GETPT
-      if test "x$ac_cv_func_getpt" = xyes; then
+      elif test "x$ac_cv_func_getpt" = xyes; then
         AC_DEFINE(PTY_OPEN, [fd = getpt ()])
         AC_DEFINE(PTY_NAME_SPRINTF, [] )
       else


^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#12040: 24.1.50; `term' hangs on FreeBSD 10.0-CURRENT without pty(4)
  2012-07-23 11:31 bug#12040: 24.1.50; `term' hangs on FreeBSD 10.0-CURRENT without pty(4) Jan Beich
@ 2012-08-16  6:45 ` Glenn Morris
       [not found] ` <1T1tp3-000F13-AB@internal.tormail.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2012-08-16  6:45 UTC (permalink / raw)
  To: Jan Beich; +Cc: 12040

Jan Beich wrote:

> A few ways to solve this:
> - use openpty() in -lutil like darwin
> - add use posix_openpt() support

Thanks for the patches.
Do you (or anyone else) have a feeling for which is the best?
As written the posix_openpt one changes the behaviour on gnu-linux
platforms to use posix_openpt instead of getpt.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#12040: 24.1.50; `term' hangs on FreeBSD 10.0-CURRENT without pty(4)
       [not found] ` <1T1tp3-000F13-AB@internal.tormail.org>
@ 2012-08-16 10:10   ` Jan Beich
  2012-08-17  7:21     ` Glenn Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Beich @ 2012-08-16 10:10 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 12040, Robert Millan

(cc'ing Robert in case I misread glibc code)

Glenn Morris <rgm@gnu.org> writes:

> Jan Beich wrote:
>
>> A few ways to solve this:
>> - use openpty() in -lutil like darwin
>> - add use posix_openpt() support
>
> Thanks for the patches.
> Do you (or anyone else) have a feeling for which is the best?

I'd go with less wrappers - posix_openpt(). And also use it on netbsd,
dragonfly and probably darwin.

openpty() is implemented via posix_openpt() in libutil on recent freebsd.

posix_openpt() is a syscall on (k)freebsd. And /dev/ptmx only exists if
pty(4) is loaded, not sure how it affects binaries under linuxulator.

> As written the posix_openpt one changes the behaviour on gnu-linux
> platforms to use posix_openpt instead of getpt.

In glibc/linux case getpt() is implemented via posix_openpt():

  // sysdeps/unix/sysv/linux/getpt.c
  int
  __getpt (void)
  {
    int fd = __posix_openpt (O_RDWR);
    if (fd == -1)
      fd = __bsd_getpt ();
    return fd;
  }

In glibc/kfreebsd case getpt() iterates over /dev/ptyXX which won't work
without pty(4) in kernel.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#12040: 24.1.50; `term' hangs on FreeBSD 10.0-CURRENT without pty(4)
  2012-08-16 10:10   ` Jan Beich
@ 2012-08-17  7:21     ` Glenn Morris
  0 siblings, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2012-08-17  7:21 UTC (permalink / raw)
  To: 12040-done

Version: 24.3

Thanks, I'm convinced. I installed the posix_openpt change for freebsd
and netbsd to the trunk, currently expected to be released as 24.3. I
left darwin alone for the time being.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-17  7:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-23 11:31 bug#12040: 24.1.50; `term' hangs on FreeBSD 10.0-CURRENT without pty(4) Jan Beich
2012-08-16  6:45 ` Glenn Morris
     [not found] ` <1T1tp3-000F13-AB@internal.tormail.org>
2012-08-16 10:10   ` Jan Beich
2012-08-17  7:21     ` Glenn Morris

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.