From 18417dfe0caeba00dd6aa45859b426ce9b76aaea Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 6 Nov 2011 15:12:39 +0900 Subject: [PATCH] BSD fixes from Bakul. --- lib/chibi/net.stub | 1 + lib/chibi/signal.c | 11 ++++++++--- tests/build/build-tests.sh | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/chibi/net.stub b/lib/chibi/net.stub index 0ccc6088..c45afd76 100644 --- a/lib/chibi/net.stub +++ b/lib/chibi/net.stub @@ -1,6 +1,7 @@ (c-system-include "sys/types.h") (c-system-include "sys/socket.h") +(c-system-include "netinet/in.h") (c-system-include "netdb.h") (define-c-int-type socklen_t) diff --git a/lib/chibi/signal.c b/lib/chibi/signal.c index baa4ff84..f4f0f1e5 100644 --- a/lib/chibi/signal.c +++ b/lib/chibi/signal.c @@ -1,5 +1,5 @@ /* 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 */ #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 -#include #include +#include +#include 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; int name[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}; if (sysctl(name, 4, &res, &reslen, NULL, 0) >= 0) { +#ifdef __APPLE__ return sexp_c_string(ctx, res.kp_proc.p_comm, -1); +#else + return sexp_c_string(ctx, res.ki_comm, -1); +#endif } else { return SEXP_FALSE; } diff --git a/tests/build/build-tests.sh b/tests/build/build-tests.sh index 9c31262f..42ecd2ca 100755 --- a/tests/build/build-tests.sh +++ b/tests/build/build-tests.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # test basic build options @@ -31,7 +31,7 @@ for opts in $(cat ${BUILDDIR}/build-opts.txt); do i=$((i+1)) done -if (( FAILURES == 0 )); then +if [ $FAILURES = 0 ]; then echo "build-tests: all tests passed" else echo "build-tests: ${FAILURES} tests failed"