Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!oberon!castor.usc.edu!blarson From: blarson@castor.usc.edu (Bob Larson) Newsgroups: comp.unix.questions Subject: Re: Fork and Join, Pipe in C Message-ID: <3128@oberon.USC.EDU> Date: Tue, 30-Jun-87 16:50:50 EDT Article-I.D.: oberon.3128 Posted: Tue Jun 30 16:50:50 1987 Date-Received: Thu, 2-Jul-87 01:29:14 EDT References: <7737@brl-adm.ARPA> <1186@ius2.cs.cmu.edu> Sender: nobody@oberon.USC.EDU Reply-To: blarson@castor.usc.edu.UUCP (Bob Larson) Organization: USC AIS, Los Angeles Lines: 32 In article <4146@teddy.UUCP> jpn@teddy.UUCP (John P. Nelson) writes: >The situations are NOT analogous. One of the most common operations >done between an fork and an exec is the modifications of the file >descriptors. Tell me, with create_process, just how would you create >an inter-process pipe? The standard code is: > > pipe(fds) > if (fork() == 0) > { > dup2(fds[1], 1); > close(fds[0]); > close(fds[1]); > exec(...); > } > close(fds[0]); On os9, which has the create_process os9fork() call rather than a unix-like fork (error checking omited for simplicity): pipe = open("/pipe", S_IREAD | S_IWRITE); temp = dup(1); close(1); dup(pipe); os9fork(...); close(1); dup(temp); close(temp); Not much harder than on on unix. Bob Larson Arpa: Blarson@Ecla.Usc.Edu Uucp: {sdcrdcf,seismo!cit-vax}!oberon!castor!blarson "How well do we use our freedom to choose the illusions we create?" -- Timbuk3