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

Re: compiling under hurd



On Mon, Sep 03, 2001 at 05:06:25PM -0400, Roland McGrath wrote:
> It is rarely appropriate to use such a conditional.
> Post your patches here first and we can advise you on the details.

I try to explain the situation. There is one file, pty.c, that define how to
create a virtual terminal. In this file some function are defined twice, and
some define are used to decide which one has to be used.

I quote some relevant piece of code:

[...]

#if !defined (__linux__) && defined(HAVE_GRANTPT)
# define USE_SYSV_PTYS
# include <sys/types.h>
# include <stropts.h>
#endif

[...]

#ifndef USE_SYSV_PTYS

#include <grp.h>
#include <sys/types.h>
#include <sys/stat.h>

static int pty_open_master_pty (int *master, char *slave_tty_name)
{
   char *a, *b;
   
   strcpy (slave_tty_name, "/dev/ptyab");
   
   a = "pqrstuvwxyz";
   while (*a != 0)
     {
	slave_tty_name [8] = *a++;
	
	b = "0123456789abcdef";
	while (*b != 0)
	  {
	     int slave;

	     slave_tty_name [9] = *b++;
	     if (-1 == (*master = signal_safe_open (slave_tty_name, O_RDWR)))
	       continue;
	     
	     /* Make sure the slave can be opened.   I attempt to set up
	      * the master terminal also even though it is not a tty and will
	      * probably fail.
	      */
	     slave_tty_name [5] = 't';
	     if (-1 != (slave = open (slave_tty_name, O_RDWR)))
	       {
		  (void) pty_setup_slave_term (slave, 1);
		  signal_safe_close (slave);
		  (void) pty_setup_slave_term (*master, 1);
		  return 0;
	       }
		  
	     signal_safe_close (*master);
	     slave_tty_name [5] = 'p';
	  }
     }
   return -1;
}
[...]

#else
static int pty_open_master_pty (int *master, char *slave_tty_name)
{
   int fd;
   char *slave_name;

   *master = -1;
   *slave_tty_name = 0;

   if (-1 == (fd = signal_safe_open ("/dev/ptmx", O_RDWR)))
     return -1;
   
   /* According to the solaris man page, this could fail if jed catches 
    * SIGCHLD.  So, I am not going to take its failure too seriously.
    */
   if (-1 == grantpt (fd))
     {
     }
   
   if (-1 == unlockpt (fd))
     {
	(void) signal_safe_close (fd);
	return -1;
     }
   
   if (NULL == (slave_name = ptsname (fd)))
     {
	(void) signal_safe_close (fd);
	return -1;
     }
   
   strcpy (slave_tty_name, slave_name);
   *master = fd;
   
   return 0;
}
[...]

I've found that only the first pty_open_master_pty() works under Hurd, but
if you compile it without patch, it uses the second one. Of course I thought
to change the first lines that I've quoted.



-- 
Saluti / Regards

Diego Roversi | diegor at maganet.net
              | diegor at tiscalinet.it 



Reply to: