Orphaned processes : Please explain

Conor P. Cahill cpcahil at virtech.uucp
Sat Sep 15 23:31:35 AEST 1990


In article <2140001 at hpnmdla.HP.COM> rajeev at hpnmdla.HP.COM (Rajeev Menon) writes:
> [ questions about pids, ppids, etc with forking processes deleted]

The key to your problem is that you can't be sure what process will 
run first following a fork (maybe the parent, maybe the child).

>Sometimes (as in case 2),the file "junk" does not contain output from all 
>the processes. Why ? Now I do

The problem you had with missing output is that you have several 
files opening & writing to the file at the same time, but you did not 
set append mode on the file.

>Some PPIDs show up as 1, showing that they have been orphaned, which could
>be expected since I am not synchonizing the processes. But it really puzzles
>me as to why this happens when I do "a.out ; cat junk" and not when I do 
>"cc fork.c ; a.out ; cat junk". Can someone explain what is going on ?

Pure chance (or actually scheduling priorities in the kernel & the effect
of other processes on cpu availability for your processes).


-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 



More information about the Comp.unix.questions mailing list