delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/01/01/10:07:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Tue, 1 Jan 2002 16:06:31 +0100
From: Corinna Vinschen <cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: duplicate regexec/regcomp functions detected
Message-ID: <20020101160631.B27340@cygbert.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20011230184457 DOT GA12386 AT redhat DOT com> <000a01c1922c$6f5d5b10$865c07d5 AT BRAMSCHE>
Mime-Version: 1.0
In-Reply-To: <000a01c1922c$6f5d5b10$865c07d5@BRAMSCHE>
User-Agent: Mutt/1.3.22.1i

On Mon, Dec 31, 2001 at 07:53:28PM +0100, Ralf Habacker wrote:
> > >- unix domain socket - The above mentioned os supports creating unix
> > >domain sockets with previous existing files.  On cygwin the unix domain
> > >sockets couldn't be bound on existing files, so it has to be removed
> > >first.
> >
> > Sounds like a bug.  Submit a patch.

It's not a bug, it's Linux compliant behaviour.  Try the following
code on Linux and Cygwin:

================================== SNIP ==============================
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>

int
main(int argc, char **argv)
{
  int sockfd;
  socklen_t len;
  struct sockaddr_un addr1, addr2;

  if (argc != 2)
    {
      fprintf (stderr, "Idiot\n");
      return 1;
    }
  sockfd = socket (AF_LOCAL, SOCK_STREAM, 0);
  if (sockfd < 0)
    {
      fprintf (stderr, "socket: %d, %s\n", errno, strerror (errno));
      return 1;
    }
  memset (&addr1, 0, sizeof addr1);
  addr1.sun_family = AF_LOCAL;
  strncpy (addr1.sun_path, argv[1], sizeof addr1.sun_path - 1);
  if (bind (sockfd, (struct sockaddr *) &addr1, SUN_LEN (&addr1)) < 0)
    {
      fprintf (stderr, "bind: %d, %s\n", errno, strerror (errno));
      return 1;
    }
  len = sizeof addr2;
  if (getsockname (sockfd, (struct sockaddr *) &addr2, &len) < 0)
    {
      fprintf (stderr, "getsockname: %d, %s\n", errno, strerror (errno));
      return 1;
    }
  printf ("bound name = %s, returned len = %d\n", addr2.sun_path, len);
  return 0;
}
================================== SNAP ==============================

Linux:
------
$ gcc -o uds uds.c
$ ./uds /tmp/foo.bar
bound name = /tmp/foo.bar, returned len = 15
$ ./uds /tmp/foo.bar
bind: 98, Address already in use

Cygwin:
-------
$ gcc -o uds uds.c
$ ./uds /tmp/foo.bar
bound name = <some random string here>, returned len = 16
$ ./uds /tmp/foo.bar
bind: 112, Address already in use

That shows that Cygwin's getsockname() doesn't return a correct
sockname for unix domain sockets but the bind() call behaves
correct.  An application that depends on (actually undocumented)
behaviour that a unix domain socket can be rebound is doing something
wrong.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019