On Mon, Jan 31, 2005 at 09:32:14PM +0800, James Matthew Miraflor wrote:
> I just want to ask, can I pass a pointer to a structure using pipes in
> C. I really want to pass the pointer to a head of a linked list, but I
> get nothing.

No, this is impossible in C.  Memory protection will see to that.  You
really ought to be reading up on some serious IPC primitives like shared
memory, semaphores, and mutexes.  Linux has support for all of these
things.  Place your linked list inside a shared memory region, and
protect all access to it with a shared mutex that should prevent race
conditions and other nasty things from occuring (if you do it right!).

If you want to keep things simple, maybe you just ought to figure out
some ad hoc way of serializing your data structure into a string, and
send that into the pipe.  Distributed references will require shared
memory or some analog thereof.

Welcome to the world of distributed programming.  Nothing is what it
seems and everything is more complicated than you think.

-- 
No fire, no heroism, no intensity of thought or feeling, can preserve a life
beyond the grave... the whole temple of man's achievement must inevitably be
buried beneath the debris of a universe in ruins.
http://stormwyrm.blogspot.com/
--
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph)
Official Website: http://plug.linux.org.ph
Searchable Archives: http://marc.free.net.ph
.
To leave, go to http://lists.q-linux.com/mailman/listinfo/plug
.
Are you a Linux newbie? To join the newbie list, go to
http://lists.q-linux.com/mailman/listinfo/ph-linux-newbie

Reply via email to