bug-gnulib
[Top][All Lists]
Advanced

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

Re: [patch] lib/login_tty.c: Controlling terminal in OpenBSD.


From: Eric Blake
Subject: Re: [patch] lib/login_tty.c: Controlling terminal in OpenBSD.
Date: Thu, 16 Sep 2010 16:11:16 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.3

On 09/16/2010 04:01 PM, Mats Erik Andersson wrote:
Hello again,

a new observation from my bug chasing.

The assumptions made in "lib/login_tty.c", which are set
on display as inherited from Solaris, these prerequisites
are __NOT__ sufficient for OpenBSD. The reason is clearly
displayed in tty(4) of OpenBSD origin. Only after an ioctl
call with TIOCSCTTY is the controlling terminal established.

Thanks for chasing this.

+#if __OpenBSD__
+# include<sys/ioctl.h>
+#endif
+
  int
  login_tty (int slave_fd)
  {
@@ -53,6 +57,11 @@ login_tty (int slave_fd)
      close (dummy_fd);
    }

+#if __OpenBSD__
+  /* Needed to activate the controlling terminal, see tty(4).  */
+  ioctl (slave_fd, TIOCSCTTY, NULL);
+#endif

Rather than hard-coding this for just __OpenBSD__, wouldn't it be better to have a configure-time check for ioctl, and:

#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#if !HAVE_FUNC_IOCTL || !defined TIOCSCTTY
# define ioctl(a, b, c) /* ignored */
#endif


so that in the function body, we can just blindly call this without #ifdefs:

  ioctl (slave_fd, TIOCSCTTY, NULL);

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

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