diff --git a/os2.rkt b/os2.rkt index cb326e8..272232c 100644 --- a/os2.rkt +++ b/os2.rkt @@ -390,9 +390,18 @@ [next-process-id (+ new-pid 1)])) (run-trapk spawned-state spawning-pid k new-pid)) +(define (print-kill pid-to-kill reason) + (cond + [(eq? reason #f) (printf "PID ~v exited normally~n" pid-to-kill)] + [(exn? reason) ((error-display-handler) + (format "PID ~v exited with exception~n~a" pid-to-kill (exn-message reason)) + reason)] + [else (printf "PID ~v exited with reason: ~a~n" pid-to-kill reason)])) + (define (do-kill pid-to-kill reason state) (cond [(hash-has-key? (vm-processes state) pid-to-kill) + (print-kill pid-to-kill reason) (define dying-endpoints (process-endpoints (hash-ref (vm-processes state) pid-to-kill))) (let* ((state (for/fold ([state state]) ([eid (in-set dying-endpoints)]) (do-unsubscribe pid-to-kill (eid-pre-eid eid) reason state))))