Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!mailrus!husc6!bloom-beacon!gatech!udel!burdvax!coltoff From: coltoff@PRC.Unisys.COM (Joel Coltoff) Newsgroups: comp.unix.wizards Subject: Help with sockets Keywords: Sun 3.4 Message-ID: <7208@burdvax.PRC.Unisys.COM> Date: 9 Aug 88 19:41:27 GMT Organization: Unisys/Paoli Research Center, Paoli, PA 19301 Lines: 32 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@burdvax.prc.unisys.com (ARPA)