From owner-freebsd-chat Wed Mar 10 9:35:53 1999 Delivered-To: freebsd-chat@freebsd.org Received: from cheddar.netmonger.net (cheddar.netmonger.net [209.54.21.140]) by hub.freebsd.org (Postfix) with ESMTP id 0138F14CA5 for ; Wed, 10 Mar 1999 09:35:50 -0800 (PST) (envelope-from chris@cheddar.netmonger.net) Received: (from chris@localhost) by cheddar.netmonger.net (8.8.8/8.8.8) id MAA03225; Wed, 10 Mar 1999 12:35:31 -0500 (EST) Message-ID: <19990310123528.A27136@netmonger.net> Date: Wed, 10 Mar 1999 12:35:28 -0500 From: Christopher Masto To: chat@freebsd.org Subject: Re: Book/URL on C programming (inter-process comms)? References: <36E6807B.2BD8FFCF@uk.radan.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.91.1i In-Reply-To: <36E6807B.2BD8FFCF@uk.radan.com>; from Mark Ovens on Wed, Mar 10, 1999 at 02:23:55PM +0000 Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Wed, Mar 10, 1999 at 02:23:55PM +0000, Mark Ovens wrote: > I've spent several hours reading through it all. Unfortunately most of > the examples show one-way communication between child and parent, > which is not what I need (I've got that bit working). > > I have managed to get what I'm trying to do *nearly* working. and have > included the code I've used below. I would appreciate it very much if > someone could spare a few minutes to look at it for me and point out > what's wrong. I'm certain that what I'm trying to do is simple but > there is something about IPC that I haven't quite grasped. Well, first of all, there are some major problems with trying to do that. You can very easily get into a deadlock if you write something and block, or if you try to read something and it's not there. To do it safely, you'll need non-blocking I/O or alarms, which takes things out of the realm of a simple example. Secondly, you're using the wrong language. scanf is not going to cooperate with unexpected input, and you'll probably be throwing stdio away anyway due to reason 1. You can find a couple of examples of bidirectional communication in the perlipc man page, along with some stern warnings. Also read perlfaq8's answer to the question, "How can I open a pipe both to and from a command?". -- Christopher Masto Director of Operations NetMonger Communications chris@netmonger.net info@netmonger.net http://www.netmonger.net Free yourself, free your machine, free the daemon -- http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message