zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: Unix domain socket module
Date: Thu, 22 Aug 2002 12:54:54 +0100	[thread overview]
Message-ID: <11860.1030017294@csr.com> (raw)
In-Reply-To: "Clint Adams"'s message of "Sat, 17 Aug 2002 22:09:05 EDT." <20020818020905.GA26266@dman.com>

Clint Adams wrote:
> This implements the zsocket builtin for IPC via local Unix domain
> sockets.  Omitted is the ability to do SOCK_DGRAM.

Minor tweaks.  `sun' is predefined on hardware from a certain vendor.
The compiler didn't like the declaration `sockaddr_un 1'.

Looks like there's no way to close an fd opened for listening since this
is beyond 9?  We could add an EXTENDED_FD option to allow `11>&-', but I
suspect the parser is going to fight this all the way.  A quick and
dirty hack (not implemented) would be to allow `zsocket -c fd' to close
any old fd.

Are you going to commit the terminfo fix for 4.0?  That looks quite
serious.

Index: Src/Modules/socket.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/socket.c,v
retrieving revision 1.1
diff -u -r1.1 socket.c
--- Src/Modules/socket.c	18 Aug 2002 02:12:39 -0000	1.1
+++ Src/Modules/socket.c	22 Aug 2002 11:25:49 -0000
@@ -63,7 +63,7 @@
     int err=1, verbose=0, test=0, targetfd=0;
     SOCKLEN_T len;
     char **dargs;
-    struct sockaddr_un sun;
+    struct sockaddr_un soun;
     int sfd;
 
     if (ops['v'])
@@ -101,12 +101,12 @@
 	    return 1;
 	}
 
-	sun.sun_family = AF_UNIX;
-	strncpy(sun.sun_path, localfn, UNIX_PATH_MAX);
+	soun.sun_family = AF_UNIX;
+	strncpy(soun.sun_path, localfn, UNIX_PATH_MAX);
 
-	if (bind(sfd, (struct sockaddr *)&sun, sizeof(struct sockaddr_un)))
+	if (bind(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))
 	{
-	    zwarnnam(nam, "could not bind to %s: %e", sun.sun_path, errno);
+	    zwarnnam(nam, "could not bind to %s: %e", soun.sun_path, errno);
 	    close(sfd);
 	    return 1;
 	}
@@ -130,7 +130,7 @@
 	setiparam("REPLY", sfd);
 
 	if (verbose)
-	    printf("%s listener is on fd %d\n", sun.sun_path, sfd);
+	    printf("%s listener is on fd %d\n", soun.sun_path, sfd);
 
 	return 0;
 
@@ -190,7 +190,8 @@
 #endif
 	}
 
-	if ((rfd = accept(lfd, (struct sockaddr *)&sun, &len)) == -1)
+	len = sizeof(soun);
+	if ((rfd = accept(lfd, (struct sockaddr *)&soun, &len)) == -1)
 	{
 	    zwarnnam(nam, "could not accept connection: %e", NULL, errno);
 	    return 1;
@@ -207,7 +208,7 @@
 	setiparam("REPLY", sfd);
 
 	if (verbose)
-	    printf("new connection from %s is on fd %d\n", sun.sun_path, sfd);
+	    printf("new connection from %s is on fd %d\n", soun.sun_path, sfd);
     }
     else
     {
@@ -223,10 +224,10 @@
 	    return 1;
 	}
 
-	sun.sun_family = AF_UNIX;
-	strncpy(sun.sun_path, dargs[0], UNIX_PATH_MAX);
+	soun.sun_family = AF_UNIX;
+	strncpy(soun.sun_path, dargs[0], UNIX_PATH_MAX);
 	
-	if ((err = connect(sfd, (struct sockaddr *)&sun, sizeof(struct sockaddr_un)))) {
+	if ((err = connect(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))) {
 	    zwarnnam(nam, "connection failed: %e", NULL, errno);
 	    close(sfd);
 	    return 1;
@@ -241,7 +242,7 @@
 	    setiparam("REPLY", sfd);
 
 	    if (verbose)
-		printf("%s is now on fd %d\n", sun.sun_path, sfd);
+		printf("%s is now on fd %d\n", soun.sun_path, sfd);
 	}
 	
     }
Index: Doc/Makefile.in
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Makefile.in,v
retrieving revision 1.15
diff -u -r1.15 Makefile.in
--- Doc/Makefile.in	12 May 2002 18:51:47 -0000	1.15
+++ Doc/Makefile.in	22 Aug 2002 11:25:49 -0000
@@ -59,7 +59,8 @@
 Zsh/mod_computil.yo \
 Zsh/mod_deltochar.yo Zsh/mod_example.yo Zsh/mod_files.yo \
 Zsh/mod_mapfile.yo Zsh/mod_mathfunc.yo Zsh/mod_parameter.yo Zsh/mod_pcre.yo \
-Zsh/mod_sched.yo Zsh/mod_stat.yo Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \
+Zsh/mod_sched.yo Zsh/mod_socket.yo \
+Zsh/mod_stat.yo Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \
 Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/mod_zleparameter.yo \
 Zsh/mod_zprof.yo Zsh/mod_zpty.yo Zsh/mod_zselect.yo \
 Zsh/mod_zutil.yo Zsh/mod_tcp.yo
Index: Doc/Zsh/mod_socket.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_socket.yo,v
retrieving revision 1.1
diff -u -r1.1 mod_socket.yo
--- Doc/Zsh/mod_socket.yo	18 Aug 2002 02:12:40 -0000	1.1
+++ Doc/Zsh/mod_socket.yo	22 Aug 2002 11:25:49 -0000
@@ -62,3 +62,4 @@
 In order to elicit more verbose output, use tt(-v).
 )
 enditem()
+)


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


  reply	other threads:[~2002-08-22 11:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-18  2:09 Clint Adams
2002-08-22 11:54 ` Peter Stephenson [this message]
2002-08-22 15:54   ` Clint Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11860.1030017294@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).