Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!lll-winken!cert!netnews.upenn.edu!grip.cis.upenn.edu!rpotter From: rpotter@grip.cis.upenn.edu (Robert Potter) Newsgroups: comp.unix.programmer Subject: generate EOF on socketpair? Message-ID: <40164@netnews.upenn.edu> Date: 31 Mar 91 21:52:26 GMT Sender: news@netnews.upenn.edu Distribution: na Organization: GRASP Lab Lines: 22 Nntp-Posting-Host: grip.cis.upenn.edu I am trying to write a replacement for popen() that returns a socket for two-way communication with some program's standard I/O. My implementation is along these lines: int process_open(...) { int sock[2]; socketpair(AF_UNIX, SOCK_STREAM, 0, sock); if (vfork() == 0) { /* are we the child? */ dup2(sock[0], 0); dup2(sock[0], 1); execv(...); } return sock[1]; } My problem: how do I indicate to the program that it has reached EOF on its standard input? I can't just close the socket, since I want to keep the socket open for reading. Do I have to set up two separate sockets (or pipes)? -Robert