Help with sockets

Joel Coltoff coltoff at PRC.Unisys.COM
Wed Aug 10 05:41:27 AEST 1988


I've got an application that uses a server to spawn a child.
For testing purposes I have a tty attached to the child as well.
My server does an

  execl( "/usr/bin/cmdtool", "cmdtool", "/usr/acct/coltoff/bin/conf", 0 );

This way I can enter debugging commands and display error messages.
>From another window I send data down the socket to the child. I am
running into problems when /usr/acct/coltoff/bin/conf tries to find the
descriptor to use as the socket. I know for a fact that in the server
it's fileno is 3. Since I was real careful to close() all unneeded
files I figured what I could do in the child was do a stat() on all
descriptors until I got back a -1 or found one that had the S_IFSOCK
bit set. The closest I get is S_IFIFO. I seems to work so I forged
blindly ahead putting off the inevitable search for an answer until
later. That happened sooner than I thought it would.

Now I am trying to get this code to work under X11 and want to
start an xterm instead of a cmdtool. The descriptor in the child
that used to be S_IFIFO is now S_IFREG and this doesn't work at all.

With that background here are my questions. How does a child program
go about finding out what descriptor is the socket from it's parent?
Should the child do a dup() on it right away so that if it does
any open() calls the socket isn't clobbered? For the brave among
you, why does the program behave one way under X11R2 and another
under suntools?

Thanks in advance.
-- 
	- Joel
		{psuvax1,sdcrdcf}!burdvax!coltoff	(UUCP)
		coltoff at burdvax.prc.unisys.com		(ARPA)



More information about the Comp.unix.wizards mailing list