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 2010/01/17 10:41:55 UTC
svn commit: r900076 - in /commons/sandbox/runtime/trunk/src/main/native: ./
include/ include/arch/unix/ os/solaris/ os/unix/ os/win32/ test/
Author: mturk
Date: Sun Jan 17 09:41:54 2010
New Revision: 900076
URL: http://svn.apache.org/viewvc?rev=900076&view=rev
Log:
Add experimental code for running su that needs pseudo terminal
Added:
commons/sandbox/runtime/trunk/src/main/native/os/solaris/openpty.c (with props)
commons/sandbox/runtime/trunk/src/main/native/os/unix/pty.c (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.in
commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_signals.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=900076&r1=900075&r2=900076&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Sun Jan 17 09:41:54 2010
@@ -143,6 +143,7 @@
$(SRCDIR)/os/unix/path.$(OBJ) \
$(SRCDIR)/os/unix/pipe.$(OBJ) \
$(SRCDIR)/os/unix/proc.$(OBJ) \
+ $(SRCDIR)/os/unix/pty.$(OBJ) \
$(SRCDIR)/os/unix/secmem.$(OBJ) \
$(SRCDIR)/os/unix/sema.$(OBJ) \
$(SRCDIR)/os/unix/shm.$(OBJ) \
@@ -182,9 +183,11 @@
$(SRCDIR)/os/unix/memalign.$(OBJ) \
$(SRCDIR)/os/unix/mmap.$(OBJ) \
$(SRCDIR)/os/unix/mutex.$(OBJ) \
+ $(SRCDIR)/os/unix/openpty.$(OBJ) \
$(SRCDIR)/os/unix/path.$(OBJ) \
$(SRCDIR)/os/unix/pipe.$(OBJ) \
$(SRCDIR)/os/unix/proc.$(OBJ) \
+ $(SRCDIR)/os/unix/pty.$(OBJ) \
$(SRCDIR)/os/unix/secmem.$(OBJ) \
$(SRCDIR)/os/unix/sema.$(OBJ) \
$(SRCDIR)/os/unix/shm.$(OBJ) \
@@ -223,6 +226,7 @@
$(SRCDIR)/os/unix/path.$(OBJ) \
$(SRCDIR)/os/unix/pipe.$(OBJ) \
$(SRCDIR)/os/unix/proc.$(OBJ) \
+ $(SRCDIR)/os/unix/pty.$(OBJ) \
$(SRCDIR)/os/unix/secmem.$(OBJ) \
$(SRCDIR)/os/unix/sema.$(OBJ) \
$(SRCDIR)/os/unix/shm.$(OBJ) \
@@ -264,6 +268,7 @@
$(SRCDIR)/os/unix/path.$(OBJ) \
$(SRCDIR)/os/unix/pipe.$(OBJ) \
$(SRCDIR)/os/unix/proc.$(OBJ) \
+ $(SRCDIR)/os/unix/pty.$(OBJ) \
$(SRCDIR)/os/unix/secmem.$(OBJ) \
$(SRCDIR)/os/unix/sema.$(OBJ) \
$(SRCDIR)/os/unix/signals.$(OBJ) \
Modified: 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=900076&r1=900075&r2=900076&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h Sun Jan 17 09:41:54 2010
@@ -73,6 +73,8 @@
acr_uid_t uid;
/** Group Id for child process */
acr_gid_t gid;
+ /** Password for su */
+ const char *password;
#endif
/** Process working directory */
acr_pchar_t *currdir;
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_signals.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_signals.h?rev=900076&r1=900075&r2=900076&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_signals.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_signals.h Sun Jan 17 09:41:54 2010
@@ -76,7 +76,7 @@
* for a given signal bypassing the original signal handler process
* might have setup before signal initialization took place.
*/
-ACR_DECLARE(acr_sigfunc_t *) ACR_SIG_DFL(int signo);
+ACR_DECLARE(int) ACR_SIG_DFL(int signo);
/**
* Ignore signal handler function for a given signal
@@ -87,7 +87,7 @@
* for a given signal bypassing the original signal handler process
* might have setup before signal initialization took place.
*/
-ACR_DECLARE(acr_sigfunc_t *) ACR_SIG_IGN(int signo);
+ACR_DECLARE(int) ACR_SIG_IGN(int signo);
/**
* Block the signal
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h?rev=900076&r1=900075&r2=900076&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h Sun Jan 17 09:41:54 2010
@@ -105,6 +105,20 @@
#define ACR_WANT_FDWALK 1
#endif
+#if HAVE_OPENPTY == 0
+int openpty(int *, int *, char *, void *, void *);
+#endif
+
+/* Macro to ensure that descriptor is
+ * above standard io descriptors
+ */
+#define FD_ABOVE_STDFILENO(D) \
+ do { \
+ if ((D) == -1 || (D) > 2) \
+ break; \
+ (D) = dup((D)); \
+ } while ((D) < 3)
+
#define ACR_IOH_CLEAR 0x8000000
typedef struct acr_ioh acr_ioh;
typedef int (acr_ioh_cleanup_fn_t)(void *, int, unsigned int);
Added: commons/sandbox/runtime/trunk/src/main/native/os/solaris/openpty.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/openpty.c?rev=900076&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/openpty.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/openpty.c Sun Jan 17 09:41:54 2010
@@ -0,0 +1,75 @@
+/* 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.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_port.h"
+#include "acr_error.h"
+
+#if HAVE_OPENPTY
+
+/* In case Solaris implements openpty one day
+ */
+UNUSED_SOURCE_FILE(openpty);
+
+#else
+#include <pwd.h>
+#include <grp.h>
+
+int my_openpty(int *amaster, int *aslave, char *name,
+ void *termp, void *winp)
+{
+ int rc = 0;
+ int master = -1;
+ int slave = -1;
+ char *ptx = NULL;
+#if HAVE_POSIX_OPENPT
+ /* Emulate openpty using posix_openpt
+ */
+ master = posix_openpt(O_RDWR | O_NOCTTY);
+ if (master == -1)
+ return -1;
+ if (grantpt(master) == -1 ||
+ unlockpt(master) == -1 ||
+ (ptx = ptsname(master)) == NULL)
+ goto cleanup;
+
+ slave = open(ptx, O_RDWR | O_NOCTTY);
+ if (slave == -1)
+ goto cleanup;
+#else
+ /* XXX: Do we need this?
+ * Solaris 10 has posix_openpt
+ */
+ errno = ENOTIMPL;
+ return -1;
+#endif
+ *amaster = master;
+ *aslave = slave;
+ if (name)
+ strlcpy(name, ptx, PATH_MAX);
+ return 0;
+
+cleanup:
+ rc = errno;
+ s_close(&master);
+ s_close(&slave);
+ errno = rc;
+ return -1;
+}
+#endif /* HAVE_OPENPTY */
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/solaris/openpty.c
------------------------------------------------------------------------------
svn:eol-style = native
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=900076&r1=900075&r2=900076&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 Sun Jan 17 09:41:54 2010
@@ -37,6 +37,7 @@
*/
extern int pipepair(int pd[2], int flags);
+extern int ptypipes(int pd[2], int flags);
extern int nullpipe(int flags, int fd);
#define PROC_TIMEOUT_STEP 100
@@ -164,6 +165,7 @@
pid_t pid;
ssize_t rd;
int i;
+ int np = 0;
int rc = 0;
int exitval;
int pipes[PIPE_COUNT] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
@@ -186,9 +188,14 @@
}
/* Create standard stream pipes
*/
- if (ep->flags & ACR_PROC_HAS_STDIN && ep->data.iov_len) {
+ if (ep->flags & ACR_PROC_HAS_STDIN) {
+#if 0
if ((rc = pipepair(&pipes[PIPE_STDINP], ACR_PIPE_READ_BLOCK)))
goto cleanup;
+#else
+ if ((rc = ptypipes(&pipes[PIPE_STDINP], ACR_PIPE_READ_BLOCK)))
+ goto cleanup;
+#endif
}
if (ep->flags & ACR_PROC_HAS_STDOUT) {
if ((rc = pipepair(&pipes[PIPE_STDOUT], ACR_PIPE_WRITE_BLOCK)))
@@ -343,18 +350,10 @@
}
/* Setup daemon signaling.
*/
- if (ACR_SIG_IGN(SIGTTOU) == SIG_ERR) {
- rc = ACR_GET_OS_ERROR();
- goto child_cleanup;
- }
- if (ACR_SIG_IGN(SIGTTIN) == SIG_ERR) {
- rc = ACR_GET_OS_ERROR();
- goto child_cleanup;
- }
- if (ACR_SIG_IGN(SIGTSTP) == SIG_ERR) {
- rc = ACR_GET_OS_ERROR();
- goto child_cleanup;
- }
+ ACR_SIG_IGN(SIGPIPE);
+ ACR_SIG_IGN(SIGTTOU);
+ ACR_SIG_IGN(SIGTTIN);
+ ACR_SIG_IGN(SIGTSTP);
/* Report our pid to the parent
*/
@@ -398,6 +397,7 @@
const char *inpp = (const char *)ep->data.iov_base;
int polltime = ep->limit.timeout > 0 ? PROC_TIMEOUT_STEP : -1;
acr_time_t endat = 0;
+ int count = 0;
/* Close parent side of pipes
*/
i_close(&pipes[PIPE_STDINP_RDS]);
@@ -441,7 +441,7 @@
}
while (pipelining) {
npipes = 0;
- if (pipes[PIPE_STDINP_WRS] != -1) {
+ if (pipes[PIPE_STDINP_WRS] != -1 && ep->data.iov_len) {
ps[npipes].fd = pipes[PIPE_STDINP_WRS];
ps[npipes].events = POLLOUT;
ps[npipes].revents = 0;
@@ -449,18 +449,17 @@
}
if (pipes[PIPE_STDOUT_RDS] != -1) {
ps[npipes].fd = pipes[PIPE_STDOUT_RDS];
- ps[npipes].events = POLLIN;
+ ps[npipes].events = POLLIN | POLLPRI;
ps[npipes].revents = 0;
npipes++;
}
if (pipes[PIPE_STDERR_RDS] != -1) {
ps[npipes].fd = pipes[PIPE_STDERR_RDS];
- ps[npipes].events = POLLIN;
+ ps[npipes].events = POLLIN | POLLPRI;
ps[npipes].revents = 0;
npipes++;
}
if (npipes) {
- i = 0;
do {
rc = poll(ps, npipes, polltime);
} while (rc == -1 && errno == EINTR);
@@ -477,56 +476,93 @@
kill(pid, 9);
break;
}
- if (pipes[PIPE_STDINP_WRS] != -1 && ps[i].revents) {
- if (ps[i].revents & POLLOUT) {
+ for (i = 0; i < rc; i++) {
+ if (ps[i].revents == 0) {
+ /* XXX: Seems that event for stderr is
+ * signaled as stdin with revents == 0
+ * but only if we are using pty for stdin.
+ */
+ ps[i].fd = pipes[PIPE_STDERR_RDS];
+ ACR_DEBUG((THROW_FMARK, "Poll with zero revents. "
+ "Redirecting stdin event to stderr!"));
+ }
+ if (pipes[PIPE_STDINP_WRS] == ps[i].fd) {
ssize_t wr;
wr = r_write(pipes[PIPE_STDINP_WRS], inpp,
ep->data.iov_len);
if (wr > 0) {
ep->data.iov_len -= wr;
inpp += wr;
+ if (ep->data.iov_len == 0) {
+ /* XXX: Closing the pseudo-terminal
+ * can cause IO error inside child.
+ */
+ i_close(&pipes[PIPE_STDINP_WRS]);
+ }
+ }
+ else {
+ if (wr != -1 || !ACR_STATUS_IS_EAGAIN(errno))
+ i_close(&pipes[PIPE_STDINP_WRS]);
}
- else
- i_close(&pipes[PIPE_STDINP_WRS]);
- }
- else {
- i_close(&pipes[PIPE_STDINP_WRS]);
}
- i++;
- }
- if (pipes[PIPE_STDOUT_RDS] != -1 && ps[i].revents) {
- if (ps[i].revents & POLLIN) {
+ if (pipes[PIPE_STDOUT_RDS] == ps[i].fd) {
char buf[512];
rd = r_read(pipes[PIPE_STDOUT_RDS], buf, sizeof(buf));
if (rd > 0) {
- /* TODO: Check for overflow
- */
- acr_sbuf_bcat(&ep->sout, buf, rd);
+ if (acr_sbuf_bcat(&ep->sout, buf, rd)) {
+ /* Error appending to the buffer.
+ * We have probably reach the limit or ENOMEM
+ */
+ pipelining = 0;
+ break;
+ }
+ if (ep->password) {
+ acr_sbuf_flush(&ep->sout);
+ if (strstr(acr_sbuf_data(&ep->sout),
+ "Password:")) {
+ inpp = ep->password;
+ ep->data.iov_len = strlen(ep->password);
+ /* One time shot */
+ ep->password = NULL;
+ }
+ }
+ }
+ else {
+ if (rd != -1 || !ACR_STATUS_IS_EAGAIN(errno))
+ i_close(&pipes[PIPE_STDOUT_RDS]);
}
- else
- i_close(&pipes[PIPE_STDOUT_RDS]);
- }
- else {
- i_close(&pipes[PIPE_STDOUT_RDS]);
}
- i++;
- }
- if (pipes[PIPE_STDERR_RDS] != -1 && ps[i].revents) {
- if (ps[i].revents & POLLIN) {
+ if (pipes[PIPE_STDERR_RDS] == ps[i].fd) {
char buf[512];
rd = r_read(pipes[PIPE_STDERR_RDS], buf, sizeof(buf));
- if (rd > 0)
- acr_sbuf_bcat(&ep->serr, buf, rd);
- else
- i_close(&pipes[PIPE_STDERR_RDS]);
- }
- else {
- i_close(&pipes[PIPE_STDERR_RDS]);
+ if (rd > 0) {
+ if (acr_sbuf_bcat(&ep->serr, buf, rd)) {
+ /* Error appending to the buffer.
+ * We have probably reach the limit or ENOMEM
+ */
+ pipelining = 0;
+ break;
+ }
+ if (ep->password) {
+ acr_sbuf_flush(&ep->serr);
+ if (strstr(acr_sbuf_data(&ep->serr),
+ "Password:")) {
+ inpp = ep->password;
+ ep->data.iov_len = strlen(ep->password);
+ /* One time shot */
+ ep->password = NULL;
+ }
+ }
+ }
+ else {
+ if (rd != -1 || !ACR_STATUS_IS_EAGAIN(errno))
+ i_close(&pipes[PIPE_STDERR_RDS]);
+ }
}
- i++;
}
+
}
else {
/* All pipes are closed
@@ -534,6 +570,7 @@
pipelining = 0;
}
}
+
/* Finished child stream processing.
* Cleanup pipes.
*/
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c?rev=900076&r1=900075&r2=900076&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c Sun Jan 17 09:41:54 2010
@@ -148,16 +148,6 @@
return rc;
}
-/* Macro to ensure that descriptor is
- * above standard io descriptors
- */
-#define FD_ABOVE_STDFILENO(D) \
- do { \
- if ((D) == -1 || (D) > 2) \
- break; \
- (D) = dup((D)); \
- } while ((D) < 3)
-
static const char *_dev_null = "/dev/null";
int nullpipe(int flags, int fd)
Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/pty.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pty.c?rev=900076&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pty.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pty.c Sun Jan 17 09:41:54 2010
@@ -0,0 +1,100 @@
+/* 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.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_port.h"
+#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_string.h"
+#include "acr_file.h"
+#include "acr_pipe.h"
+
+/**
+ * Unix pseudo-terminal wrapper
+ *
+ */
+#include <termios.h>
+#if HAVE_PTY_H
+#include <pty.h>
+#endif
+#if HAVE_UTIL_H
+#include <util.h>
+#endif
+
+
+static int _setptyraw(int fd)
+{
+ int rc;
+ struct termios term;
+
+ do {
+ rc = tcgetattr(fd, &term);
+ } while (rc == -1 && errno == EINTR);
+
+ if (rc)
+ return -1;
+ /* Linux man page defined 'raw' terminal with the following
+ * flags set:
+ */
+ term.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
+ term.c_oflag &= ~OPOST;
+ term.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
+ term.c_cflag &= ~(CSIZE | PARENB);
+ term.c_cflag |= CS8;
+
+ do {
+ rc = tcsetattr(fd, TCSANOW, &term);
+ } while (rc == -1 && errno == EINTR);
+
+ return rc;
+}
+
+int ptypipes(int pd[2], int flags)
+{
+ int rc = 0;
+
+ if (openpty(&pd[0], &pd[1], NULL, NULL, NULL) == -1)
+ return ACR_GET_OS_ERROR();
+ /* Move descriptors above stderr
+ */
+ FD_ABOVE_STDFILENO(pd[0]);
+ FD_ABOVE_STDFILENO(pd[1]);
+
+ if (pd[0] == -1 || pd[1] == -1)
+ return ACR_GET_OS_ERROR();
+ _setptyraw(pd[0]);
+ _setptyraw(pd[1]);
+ if (flags == ACR_PIPE_WRITE_BLOCK ||
+ flags == ACR_PIPE_FULL_NONBLOCK) {
+ if ((rc = acr_nonblock(pd[0], 1)))
+ goto finally;
+ }
+ if (flags == ACR_PIPE_READ_BLOCK ||
+ flags == ACR_PIPE_FULL_NONBLOCK) {
+ if ((rc = acr_nonblock(pd[1], 1)))
+ goto finally;
+ }
+ return 0;
+
+finally:
+ s_close(pd[0]);
+ s_close(pd[1]);
+
+ return rc;
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/unix/pty.c
------------------------------------------------------------------------------
svn:eol-style = native
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=900076&r1=900075&r2=900076&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 Sun Jan 17 09:41:54 2010
@@ -288,14 +288,14 @@
return oact.sa_handler;
}
-ACR_DECLARE(acr_sigfunc_t *) ACR_SIG_DFL(int signo)
+ACR_DECLARE(int) ACR_SIG_DFL(int signo)
{
int rc;
struct sigaction act, oact;
if (signo < 1 || signo > ACR_NUMSIG) {
errno = EINVAL;
- return SIG_ERR;
+ return -1;
}
memset(&act, 0, sizeof(struct sigaction));
@@ -315,21 +315,17 @@
if (signo == SIGCHLD)
act.sa_flags |= SA_NOCLDWAIT;
#endif
- rc = sigaction(signo, &act, &oact);
- if (rc < 0)
- return SIG_ERR;
- else
- return oact.sa_handler;
+ return sigaction(signo, &act, NULL);
}
-ACR_DECLARE(acr_sigfunc_t *) ACR_SIG_IGN(int signo)
+ACR_DECLARE(int) ACR_SIG_IGN(int signo)
{
int rc;
- struct sigaction act, oact;
+ struct sigaction act;
if (signo < 1 || signo > ACR_NUMSIG) {
errno = EINVAL;
- return SIG_ERR;
+ return -1;
}
memset(&act, 0, sizeof(struct sigaction));
@@ -357,11 +353,7 @@
if (signo == SIGCHLD)
act.sa_handler = avoid_zombies;
#endif
- rc = sigaction(signo, &act, &oact);
- if (rc < 0)
- return SIG_ERR;
- else
- return oact.sa_handler;
+ return sigaction(signo, &act, NULL);
}
ACR_DECLARE(int) ACR_SignalBlock(int signum)
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=900076&r1=900075&r2=900076&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 Sun Jan 17 09:41:54 2010
@@ -841,14 +841,14 @@
return orghandler;
}
-ACR_DECLARE(acr_sigfunc_t *) ACR_SIG_DFL(int signo)
+ACR_DECLARE(int) ACR_SIG_DFL(int signo)
{
- return ACR_Signal(signo, SIG_DFL);
+ return ACR_Signal(signo, SIG_DFL) == SIG_ERR ? -1 : 0
}
-ACR_DECLARE(acr_sigfunc_t *) ACR_SIG_IGN(int signo)
+ACR_DECLARE(int) ACR_SIG_IGN(int signo)
{
- return ACR_Signal(signo, SIG_IGN);
+ return ACR_Signal(signo, SIG_IGN) == SIG_ERR ? -1 : 0
}
ACR_DECLARE(int) ACR_SignalSetKey(const wchar_t *key)
Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=900076&r1=900075&r2=900076&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Sun Jan 17 09:41:54 2010
@@ -686,10 +686,11 @@
return ACR_EINVAL;
}
exe = ACR_ExecNew(ACR_PROC_HAS_STDOUT | ACR_PROC_HAS_STDERR | ACR_PROC_HAS_STDIN);
- ACR_ExecStdinSet(exe, hello, strlen(hello));
#if defined(WIN32)
+
rc = ACR_ExecSubproc(exe, NULL, wargv[0], &wargv[1], NULL);
#else
+ exe->password = "su password";
rc = ACR_ExecProgram(exe, argv[0], &argv[1], NULL);
#endif
fprintf(stdout, "[STDOUT]:\n%s", ACR_ExecStream(exe, 1));