BSD fixes from Bakul.

This commit is contained in:
Alex Shinn 2011-11-06 15:12:39 +09:00
parent e768616433
commit 18417dfe0c
3 changed files with 11 additions and 5 deletions

View file

@ -1,6 +1,7 @@
(c-system-include "sys/types.h") (c-system-include "sys/types.h")
(c-system-include "sys/socket.h") (c-system-include "sys/socket.h")
(c-system-include "netinet/in.h")
(c-system-include "netdb.h") (c-system-include "netdb.h")
(define-c-int-type socklen_t) (define-c-int-type socklen_t)

View file

@ -1,5 +1,5 @@
/* signal.c -- process signals interface */ /* signal.c -- process signals interface */
/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ /* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */ /* BSD-style license: http://synthcode.com/license.txt */
#define SEXP_MAX_SIGNUM 32 #define SEXP_MAX_SIGNUM 32
@ -64,15 +64,20 @@ static sexp sexp_set_signal_action (sexp ctx, sexp self, sexp signum, sexp newac
#if SEXP_BSD #if SEXP_BSD
#include <sys/sysctl.h>
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/user.h>
static sexp sexp_pid_cmdline (sexp ctx, int pid) { static sexp sexp_pid_cmdline (sexp ctx, int pid) {
unsigned long reslen = sizeof(struct kinfo_proc); size_t reslen = sizeof(struct kinfo_proc);
struct kinfo_proc res; struct kinfo_proc res;
int name[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}; int name[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
if (sysctl(name, 4, &res, &reslen, NULL, 0) >= 0) { if (sysctl(name, 4, &res, &reslen, NULL, 0) >= 0) {
#ifdef __APPLE__
return sexp_c_string(ctx, res.kp_proc.p_comm, -1); return sexp_c_string(ctx, res.kp_proc.p_comm, -1);
#else
return sexp_c_string(ctx, res.ki_comm, -1);
#endif
} else { } else {
return SEXP_FALSE; return SEXP_FALSE;
} }

View file

@ -1,4 +1,4 @@
#! /bin/bash #!/bin/sh
# test basic build options # test basic build options
@ -31,7 +31,7 @@ for opts in $(cat ${BUILDDIR}/build-opts.txt); do
i=$((i+1)) i=$((i+1))
done done
if (( FAILURES == 0 )); then if [ $FAILURES = 0 ]; then
echo "build-tests: all tests passed" echo "build-tests: all tests passed"
else else
echo "build-tests: ${FAILURES} tests failed" echo "build-tests: ${FAILURES} tests failed"