I know I’m going to need to use fork(), but this just creates a single child process. Do i simply call fork again from within the child process? Also, I need them to communicate through a signal or pipe, which is easier to implement and what do i need to know for doing that (functions, etc..)
Share
To create a second process, call
fork()again – either within the parent or the child (but not both!). Which you choose depends on whether you want this process to be a child of the original parent or a child of the first child process (it is usual for it to be a child of the original parent).Communicating through a pipe is much simpler and more reliable than using signals.
pipe(),close(),read(),write()andselect()are the key functions here.For example, to have the parent create two child processes, you would do something like: