Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Mar 1999 12:35:28 -0500
From:      Christopher Masto <chris@netmonger.net>
To:        chat@freebsd.org
Subject:   Re: Book/URL on C programming (inter-process comms)?
Message-ID:  <19990310123528.A27136@netmonger.net>
In-Reply-To: <36E6807B.2BD8FFCF@uk.radan.com>; from Mark Ovens on Wed, Mar 10, 1999 at 02:23:55PM %2B0000
References:  <Pine.OSF.4.02.9903081815220.25487-100000@fly.HiWAAY.net> <36E6807B.2BD8FFCF@uk.radan.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990310123528.A27136>