* Fork, posix-fork, and waitpid are implemented.

This commit is contained in:
Abdulaziz Ghuloum 2007-01-01 02:02:41 +03:00
parent eb24d17049
commit a5618ef877
5 changed files with 32 additions and 12 deletions

Binary file not shown.

View File

@ -905,3 +905,16 @@ ikrt_bytes_allocated_major(ikpcb* pcb){
return fix(pcb->allocation_count_major); return fix(pcb->allocation_count_major);
} }
ikp
ikrt_fork(){
int pid = fork();
return fix(pid);
}
ikp
ikrt_waitpid(ikp pid){
int status;
pid_t t = waitpid(unfix(pid), &status, 0);
return fix(t);
}

Binary file not shown.

View File

@ -1,16 +1,22 @@
;;; ($pcb-set! posix-fork (primitive-set! 'posix-fork
;;; (lambda () (lambda ()
;;; (foreign-call "S_fork"))) (foreign-call "ikrt_fork")))
;;;
;;; ($pcb-set! fork (primitive-set! 'fork
;;; (lambda (parent-proc child-proc) (lambda (parent-proc child-proc)
;;; (let ([pid (posix-fork)]) (let ([pid (posix-fork)])
;;; (cond (cond
;;; [(fx= pid 0) (child-proc)] [(fx= pid 0) (child-proc)]
;;; [(fx= pid -1) [(fx= pid -1)
;;; (error 'fork "failed")] (error 'fork "failed")]
;;; [else (parent-proc pid)])))) [else (parent-proc pid)]))))
(primitive-set! 'waitpid
(lambda (pid)
(unless (fixnum? pid)
(error 'waitpid "~s is not a fixnum" pid))
(foreign-call "ikrt_waitpid" pid)))
(primitive-set! 'system (primitive-set! 'system
(lambda (x) (lambda (x)

View File

@ -86,6 +86,7 @@
make-guardian weak-cons collect make-guardian weak-cons collect
interrupt-handler interrupt-handler
time-it time-it
posix-fork fork waitpid
)) ))
(define system-primitives (define system-primitives