*BSD News Article 72000


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!fu-berlin.de!news.belwue.de!news.uni-stuttgart.de!uniol!uni-erlangen.de!news.tu-chemnitz.de!irz401!orion.sax.de!uriah.heep!news
From: j@uriah.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: socketpair() in 2.2-960612-SNAP
Date: 25 Jun 1996 21:46:06 GMT
Organization: Private BSD site, Dresden
Lines: 38
Message-ID: <4qpmmu$juf@uriah.heep.sax.de>
References: <boris-2606960052300001@boris.macsimum.gamma.ru>
Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch)
NNTP-Posting-Host: localhost.heep.sax.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: knews 0.9.6
X-Phone: +49-351-2012 669
X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F  93 21 E0 7D F9 12 D6 4E

boris@macsimum.gamma.ru (Boris Lavrinovich) wrote:

> Oh, I have found where the problem is. socketpair() actually succeeded but
> returned the value of first descriptor in pair instead of 0. This is
> strange because it does not conform to man page (I am not sure wheither it
> comforms to POSIX too).

I think Posix (at least the ``classic'' ones) is irrelevant here since
it doesn't standardize socket IPC (yet).

I think what you're describing is rather an unwanted side-effect of
the implementation.  Watch out the question marks:

	error = copyout((caddr_t)sv, (caddr_t)uap->rsv, 2 * sizeof (int));
	retval[0] = sv[0];		/* XXX ??? */
	retval[1] = sv[1];		/* XXX ??? */
	return (error);

socketpair() is a bit special in its return value handling in that it
does return two values (pipe() is another example).  Thus, the regular
retval handling is not actually used but an explicit copyout() inside
the kernel function for socketpair().  (Normal return values are being
passed through the register %eax, so no copyout is needed.)

pipe() is handled differently, it doesn't copyout either, but passes
the return value through two registers.  This requires a separate,
specific stub in the libc implementation (different from the `generic'
syscalls), but seems the way to go for socketpair() as well.


You might want to submit a PR for this.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)