mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
tl;dr process-running? would always return #f on OpenBSD and NetBSD, and in the one-argument case it would always return #t on DragonFly. To get the process information from the process table on OpenBSD and NetBSD, we need to pass 6 level names to sysctl instead of 4. Passing the wrong number of level names to sysctl has caused it to always fail, which in turn caused process-running? to always return #f: (process-running? 1) => #f (process-running? (current-process-id)) => #f and so on. After the above fix, we also need to check the amount of data actually filled in by sysctl. It appears that on OpenBSD, NetBSD and DragonFly, if the requested process doesn't exist then sysctl will return with a return value of 0 and just not actually fill in the given structure. This caused process-running? to return #t when no process with the given PID existed: (process-running? -1) => #t (process-running? <other nonexistent pid>) => #t and so on. I have tested on OpenBSD, NetBSD, DragonFly BSD and FreeBSD, and process-running? now behaves as expected on all of them.
26 lines
1.2 KiB
Scheme
26 lines
1.2 KiB
Scheme
(define-library (chibi process-test)
|
|
(export run-tests)
|
|
(import (chibi) (chibi process) (only (chibi test) test-begin test test-end))
|
|
(begin
|
|
(define (run-tests)
|
|
(test-begin "processes")
|
|
(test #t (process-running? (current-process-id)))
|
|
(test #t (process-running? (parent-process-id)))
|
|
(test #f (process-running? -1))
|
|
(test #f (signal-set-contains? (current-signal-mask) signal/alarm))
|
|
(test #t (signal-set? (make-signal-set)))
|
|
(test #t (signal-set? (current-signal-mask)))
|
|
(test #f (signal-set? #f))
|
|
(test #f (signal-set? '(#f)))
|
|
(test #f (signal-set-contains? (make-signal-set) signal/interrupt))
|
|
(test #t (let ((sset (make-signal-set)))
|
|
(signal-set-fill! sset)
|
|
(signal-set-contains? sset signal/interrupt)))
|
|
(test #t (let ((sset (make-signal-set)))
|
|
(signal-set-add! sset signal/interrupt)
|
|
(signal-set-contains? sset signal/interrupt)))
|
|
(test #f (let ((sset (make-signal-set)))
|
|
(signal-set-fill! sset)
|
|
(signal-set-delete! sset signal/interrupt)
|
|
(signal-set-contains? sset signal/interrupt)))
|
|
(test-end))))
|