You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/12/29 13:05:01 UTC
svn commit: r894363 - in /commons/sandbox/runtime/trunk/src/main/native:
configure include/acr_exec.h include/acr_proc.h
include/arch/windows/acr_arch.h os/unix/exec.c os/unix/signals.c
os/win32/signals.c
Author: mturk
Date: Tue Dec 29 12:05:00 2009
New Revision: 894363
URL: http://svn.apache.org/viewvc?rev=894363&view=rev
Log:
Port APR's signal block/unblock
Added:
commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h (with props)
commons/sandbox/runtime/trunk/src/main/native/include/acr_proc.h (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/configure
commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=894363&r1=894362&r2=894363&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Tue Dec 29 12:05:00 2009
@@ -1199,6 +1199,7 @@
#define HAVE_EVENTFD2 `have_function 0 eventfd2`
#define HAVE_SIGNALFD `have_function 0 signalfd`
#define HAVE_FDWALK `have_function 0 fdwalk`
+#define HAVE_PIPE2 `have_function 0 pipe2`
#define HAVE_SOCK_CLOEXEC `have_defined SOCK_CLOEXEC`
#define HAVE_FILE_CLOEXEC `have_defined O_CLOEXEC`
#define HAVE_OFF64_T $have_off64t
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h?rev=894363&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h Tue Dec 29 12:05:00 2009
@@ -0,0 +1,40 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACR_EXEC_H
+#define _ACR_EXEC_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_exec.h
+ * @brief
+ *
+ * ACR Process execution functions
+ *
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_EXEC_H */
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_proc.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_proc.h?rev=894363&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_proc.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_proc.h Tue Dec 29 12:05:00 2009
@@ -0,0 +1,40 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACR_PROC_H
+#define _ACR_PROC_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_proc.h
+ * @brief
+ *
+ * ACR Process functions
+ *
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_PROC_H */
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_proc.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=894363&r1=894362&r2=894363&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Tue Dec 29 12:05:00 2009
@@ -572,8 +572,32 @@
return (*set & sigmask(signo)) != 0;
}
-#define sigemptyset(S) *(S) = 0
-#define sigfillset(S) *(S) = ~(sigset_t)0
+sigmask_t sigsetmask(sigmask_t);
+
+#define sigemptyset(S) InterlockedExchange((S), 0)
+#define sigfillset(S) InterlockedExchange((S), ~(sigset_t)0)
+
+static ACR_INLINE int sigprocmask(int how, const sigset_t *set,
+ sigset_t *oldset)
+{
+ sigset_t current = sigsetmask(0);
+
+ if (oldset)
+ *oldset = current;
+ switch (how) {
+ case SIG_BLOCK:
+ current |= *set;
+ break;
+ case SIG_UNBLOCK:
+ current &= ~*mask;
+ break;
+ case SIG_SETMASK:
+ current = *mask;
+ break;
+ }
+ sigsetmask(current);
+ return 0;
+}
/*
* ---------------------------------------------------------------------
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c?rev=894363&r1=894362&r2=894363&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c Tue Dec 29 12:05:00 2009
@@ -19,12 +19,19 @@
#include "acr_arch.h"
#include "acr_port.h"
#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_signals.h"
#include "acr_string.h"
#include "acr_descriptor.h"
#include "acr_file.h"
-#include "acr_port.h"
+#include "acr_exec.h"
/**
* Posix process execution functions
*
*/
+
+#define PIPE_RDS 0
+#define PIPE_WRS 1
+
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c?rev=894363&r1=894362&r2=894363&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c Tue Dec 29 12:05:00 2009
@@ -272,3 +272,38 @@
return SIG_ERR;
return oact.sa_handler;
}
+
+ACR_DECLARE(int) ACR_SignalBlock(int signum)
+{
+ sigset_t sig_mask;
+ int rv;
+
+ sigemptyset(&sig_mask);
+ sigaddset(&sig_mask, signum);
+
+#if defined(DARWIN)
+ if ((rv = sigprocmask(SIG_BLOCK, &sig_mask, NULL)) != 0)
+ rv = errno;
+#else
+ rv = pthread_sigmask(SIG_BLOCK, &sig_mask, NULL);
+#endif
+ return rv;
+}
+
+ACR_DECLARE(int) ACR_SignalUnblock(int signum)
+{
+ sigset_t sig_mask;
+ int rv;
+
+ sigemptyset(&sig_mask);
+ sigaddset(&sig_mask, signum);
+
+#if defined(DARWIN)
+ if ((rv = sigprocmask(SIG_UNBLOCK, &sig_mask, NULL)) != 0)
+ rv = errno;
+#else
+ rv = pthread_sigmask(SIG_UNBLOCK, &sig_mask, NULL);
+#endif
+ return rv;
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c?rev=894363&r1=894362&r2=894363&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c Tue Dec 29 12:05:00 2009
@@ -560,6 +560,11 @@
return 0;
}
+sigmask_t sigsetmask(sigmask_t set)
+{
+ return InterlockedExchange(¤t_signal_mask, set);
+}
+
int acr_SignalsInit()
{
HANDLE h;
@@ -850,6 +855,26 @@
return 0;
}
+ACR_DECLARE(int) ACR_SignalBlock(int signum)
+{
+ sigset_t sig_mask;
+
+ sigemptyset(&sig_mask);
+ sigaddset(&sig_mask, signum);
+
+ return sigprocmask(SIG_BLOCK, &sig_mask, NULL);
+}
+
+ACR_DECLARE(int) ACR_SignalUnblock(int signum)
+{
+ sigset_t sig_mask;
+
+ sigemptyset(&sig_mask);
+ sigaddset(&sig_mask, signum);
+
+ return sigprocmask(SIG_UNBLOCK, &sig_mask, NULL);
+}
+
int acr_SignalsCleanup(void)
{
int rc = ACR_SUCCESS;
@@ -866,3 +891,4 @@
}
return rc;
}
+