mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-06 20:56:38 +02:00
Merge pull request #564 from katterjohn/process-bsd-fix
(chibi process): fix process-running? on OpenBSD, NetBSD and DragonFly
This commit is contained in:
commit
ae98680259
2 changed files with 8 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
|||
(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)))
|
||||
|
|
|
@ -83,8 +83,14 @@ static sexp sexp_pid_cmdline (sexp ctx, int pid) {
|
|||
int id = KERN_PROC;
|
||||
#endif
|
||||
size_t reslen = sizeof(res);
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
int name[6] = {CTL_KERN, id, KERN_PROC_PID, pid, reslen, 1};
|
||||
unsigned namelen = 6;
|
||||
#else
|
||||
int name[4] = {CTL_KERN, id, KERN_PROC_PID, pid};
|
||||
if (sysctl(name, 4, &res, &reslen, NULL, 0) >= 0) {
|
||||
unsigned namelen = 4;
|
||||
#endif
|
||||
if (sysctl(name, namelen, &res, &reslen, NULL, 0) >= 0 && reslen > 0) {
|
||||
#if defined(__APPLE__)
|
||||
return sexp_c_string(ctx, res.kp_proc.p_comm, -1);
|
||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
|
|
Loading…
Add table
Reference in a new issue