diff options
Diffstat (limited to 'src/lib9')
-rw-r--r-- | src/lib9/9proc.h | 2 | ||||
-rw-r--r-- | src/lib9/_p9proc.c | 13 | ||||
-rw-r--r-- | src/lib9/fork.c | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/lib9/9proc.h b/src/lib9/9proc.h index 663d65b6..1f471b6f 100644 --- a/src/lib9/9proc.h +++ b/src/lib9/9proc.h @@ -18,3 +18,5 @@ struct Uproc extern Uproc *_p9uproc(int); extern void _p9uprocdie(void); +extern void _clearuproc(void); + diff --git a/src/lib9/_p9proc.c b/src/lib9/_p9proc.c index c492ae15..9543bf24 100644 --- a/src/lib9/_p9proc.c +++ b/src/lib9/_p9proc.c @@ -18,6 +18,19 @@ static Uproc *alluproc[PIDHASH]; static int allupid[PIDHASH]; static Lock uproclock; +void +_clearuproc(void) +{ + int i; + + /* called right after fork - no locking needed */ + for(i=0; i<PIDHASH; i++) + if(alluproc[i] != T && alluproc[i] != 0) + free(alluproc[i]); + memset(alluproc, 0, sizeof alluproc); + memset(allupid, 0, sizeof allupid); +} + Uproc* _p9uproc(int inhandler) { diff --git a/src/lib9/fork.c b/src/lib9/fork.c index 99e84dc9..4dbff87b 100644 --- a/src/lib9/fork.c +++ b/src/lib9/fork.c @@ -9,6 +9,7 @@ p9fork(void) int pid; pid = fork(); + _clearuproc(); _p9uproc(0); return pid; } |