On Mon, 31 Jan 2005 21:32:14 +0800, James Matthew Miraflor <[EMAIL PROTECTED]> 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.
i don't have my copy of Stevens beside me right now, but i don't think you can do that. the basic problem, IMO, is that you're trying to pass a pointer to memory from one process to another. even if the processes have a parent-child (forker-forkee) relationship, and the child gets a copy of the parent's address space at fork time, after the child starts executing, their memory use diverges and a pointer allocated in one will no longer point to the same thing in the other. it *might* be that memory that was allocated before the call to fork will be the same in both parent and child, but if this is a dynamic data structure, that's not going to help you much since any changes to the linked list in the parent will not be reflected in the child. you'll want to use shared memory for this. or maybe the child can ask the parent for the values of things (but then that opens its own can of worms since the parent will be doing its own thing and won't appreciate asynchronous requests for list data from the children). can you make your program multi-threaded instead of forking off children? tiger -- Gerald Timothy Quimpo http://bopolissimus.blogspot.com [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Public Key: "gpg --keyserver pgp.mit.edu --recv-keys 672F4C78" Mene sakhet ur-seveh -- 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
