forks, ipc, fifos, update issues...

Hi, so I've got this program("main") that fork executes another ("user"). These programs communicate through fifos.

One communication is a spawn call, where user passes an executable, main forks and executes it. So, I'm keeping track of all my processes using a task table. After the fork (for the spawn call), the new child adds itself to the task table and then waits for the "user" to finish before executing. So, the user finishes what it needs, calls the end method on "main", which checks to see if there's a waiting process. It turns out when I show() my task table, the new child that I added isn't there! I can't figure out why at all. Any ideas?

Here's the 2nd child when it gets created.


pid = Fork(); 
if(pid == 0) { 
      //blah blah 
      tbl -> set(spawn_tid_c, spawn_pid_c); 
      tbl -> show(); 
      //wait 
}

Here's the output.

+ main + forking
+ TaskTbl + set(01, 19976) method called
+ TaskTbl + (01, 19976) added
<TaskTbl> has 2 items
0: <00,19975>
1: <01,19976>
+ main + waiting for system call message
+ user1 + calling s_end()
+ main + syscall task end received
<TaskTbl> has 1 items
0: <00,19975>

the end function is called immediately after the spawn function finishes, and I've checked everywhere to find something that would remove the task but the only way to do so would be for me to intentionally remove it ( remove -> (task, proc)), which I'm not doing.

I have no idea why the table is only showing 1 item immediately after. Help would be greatly appreciated.

Hi,
I am not getting a clear idea of what is happening.
Do you mean to say that the child part of fork is never executed?
or is it executed only once. Is show() by any chance using an exec function.

Please clarify the problem.

so program starts, main forks and executes child1, there's some communication, child1 sends a spawn message to main, but the new child needs to wait until the first child finishes. So, main forks, new child adds itself to the task table and begins to wait until child1 is finished. Main proceeds with child1 until it's done. Immediately after child1 is done, the new child executes child2, etc. I need to tell my main that there is a child waiting, and the order of execution so I use a task table. problem is after child1 is done, while new child (not yet executed child2) is waiting, main checks tasktable to see if there's another entry, which for some reason there isn't, but there should be.

and no, show is a call to TaskTable class which just displays entries. Any more questions just ask. Thanks for help.

This might sound trite, but are you sure there is no arrray index issue?

the only array index is inside tasktable, which i've tested on a nonforking program multiple adds and removes, etc. and it all works fine. updating it with 2 processes apparenlty doesn't share.

Tell me something, after the first child proc has finished executing, it should *not* show up in the task table right? and you should see the second one? or is the task table supposed to have all entries at all times?

Is this table in explicitly shared memory? If not, each process gets it's own copy along with it's own independent memory space. Changes in one won't change any of the others. This is very different from threading, where everything lives in the same memory space.