Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed May 26, 2024
1 parent f41a61f commit 0673eae
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 24 deletions.
13 changes: 11 additions & 2 deletions lib/chibi/process.scm
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
(define unwind #f)

((call/cc
(lambda (k)
(set! unwind k)
(lambda () #f))))

(cond-expand
(plan9
(define (exit . o)
(define (emergency-exit . o)
(%exit (if (pair? o)
(if (string? (car o))
(car o)
(if (eq? #t (car o)) "" "chibi error"))
""))))
(else
(define (exit . o)
(define (emergency-exit . o)
(%exit (if (pair? o)
(if (integer? (car o))
(inexact->exact (car o))
(if (eq? #t (car o)) 0 1))
0)))))

(define (exit . o)
(unwind (lambda () (apply emergency-exit o))))

(cond-expand
(bsd
(define (process-command-line pid)
Expand Down
5 changes: 3 additions & 2 deletions lib/chibi/process.sld
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

(define-library (chibi process)
(export exit sleep alarm %fork fork kill execute waitpid system system?
process-command-line process-running?
(export exit emergency-exit sleep alarm
%fork fork kill execute waitpid system system?
process-command-line process-running?
set-signal-action! make-signal-set
signal-set? signal-set-contains?
signal-set-fill! signal-set-add! signal-set-delete!
Expand Down
12 changes: 11 additions & 1 deletion lib/chibi/win32/process-win32.scm
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
(define (exit . code?)
(define unwind #f)

((call/cc
(lambda (k)
(set! unwind k)
(lambda () #f))))

(define (emergency-exit . code?)
(%exit (if (pair? code?)
(let ((c (car code?)))
(cond ((integer? c) c)
((eq? #t c) 0)
(else 1)))
0)))

(define (exit . o)
(unwind (lambda () (apply emergency-exit o))))
4 changes: 2 additions & 2 deletions lib/chibi/win32/process-win32.sld
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(define-library (chibi win32 process-win32)
(import (scheme base))
(export exit)
(export exit emergency-exit)
(cond-expand
(windows
(include-shared "process-win32")
(include "process-win32.scm"))
(else
(import (only (chibi process) exit)))))
(import (only (chibi process) exit emergency-exit)))))
21 changes: 4 additions & 17 deletions lib/scheme/process-context.sld
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@

(define-library (scheme process-context)
(import (chibi) (only (scheme base) call/cc) (srfi 98))
(cond-expand (windows (import (prefix (only (chibi win32 process-win32) exit) process-)))
(else (import (prefix (only (chibi process) exit) process-))))
(import (chibi) (srfi 98))
(cond-expand (windows (import (only (chibi win32 process-win32) exit emergency-exit)))
(else (import (only (chibi process) exit emergency-exit))))
(export get-environment-variable get-environment-variables
command-line exit emergency-exit)

(begin
(define unwind #f)

((call/cc
(lambda (cont)
(set! unwind cont)
(lambda () #f))))

(define emergency-exit process-exit)

(define (exit . rest)
(unwind (lambda () (apply emergency-exit rest))))))
command-line exit emergency-exit))

0 comments on commit 0673eae

Please sign in to comment.