Passing 0 to accept(2) as second and third argument.

Keith Gabryelski ag at cbmvax.UUCP
Mon Sep 18 10:45:12 AEST 1989


I've seen two examples of the following code fragement:

	while (accept(s, 0, 0) < 0) {
		...
	}

found in talk and X Windows.  Under our current socket implementation
this above code fragment will return EFAULT which seems entirely
reasonable to me since the second and third arguments to accept() are
suppose to be pointers to user memory for return values.

Since:

	struct sockaddr dummyaddr;
	int dummylen = sizeof struct sockaddr;

	accept(s, &dummyaddr, &dummylen);

seems more reasonable to me than having the kernel check for these two
sigularities (twoplearity?) I am wondering if this is actually
considered a feature that should be supported and accepted or if this
is just a hand me down that people have gotten use to.

BTW, passing a null pointer as the second or third argument to
accept() is not documented under any of the accept man pages I've read
(Ultrix and SunOs).

-- 
 "It took no computation to dance to the rock 'n roll station" -- VU
  ag at cbmvax.commodore.com     Keith M. Gabryelski      ...!uunet!cbmvax!ag



More information about the Comp.unix.wizards mailing list