You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/01/08 02:10:29 UTC
svn commit: r897073 - in
/commons/proper/daemon/trunk/src/native/unix/native: arguments.c
arguments.h help.c jsvc-unix.c
Author: sebb
Date: Fri Jan 8 01:10:29 2010
New Revision: 897073
URL: http://svn.apache.org/viewvc?rev=897073&view=rev
Log:
DAEMON-105 Add command line switch to redirect stdin
Modified:
commons/proper/daemon/trunk/src/native/unix/native/arguments.c
commons/proper/daemon/trunk/src/native/unix/native/arguments.h
commons/proper/daemon/trunk/src/native/unix/native/help.c
commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c
Modified: commons/proper/daemon/trunk/src/native/unix/native/arguments.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/arguments.c?rev=897073&r1=897072&r2=897073&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/arguments.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/arguments.c Fri Jan 8 01:10:29 2010
@@ -56,6 +56,7 @@
args->anum=0; /* Zero class specific arguments but make room*/
args->outfile="/dev/null"; /* Swallow by default */
args->errfile="/dev/null"; /* Swallow by default */
+ args->redirectstdin=true; /* Redirect stdin to /dev/null by default */
args->args=(char **)malloc(argc*sizeof(char *));
args->procname = "jsvc.exec";
/* Set up the command name */
@@ -135,6 +136,9 @@
} else if (strcmp(argv[x],"-nodetach")==0) {
args->dtch=false;
+ } else if (strcmp(argv[x], "-keepstdin")==0) {
+ args->redirectstdin = false;
+
} else if (strcmp(argv[x],"-service")==0) {
args->service=true;
Modified: commons/proper/daemon/trunk/src/native/unix/native/arguments.h
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/arguments.h?rev=897073&r1=897072&r2=897073&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/arguments.h (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/arguments.h Fri Jan 8 01:10:29 2010
@@ -68,6 +68,8 @@
char *errfile;
/** Program name for Linux **/
char *procname;
+ /** Whether to redirect stdin to /dev/null or not. Defaults to true **/
+ bool redirectstdin;
} arg_data;
/**
Modified: commons/proper/daemon/trunk/src/native/unix/native/help.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/help.c?rev=897073&r1=897072&r2=897073&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/help.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/help.c Fri Jan 8 01:10:29 2010
@@ -90,5 +90,8 @@
printf(" -stop\n");
printf(" stop the service using the file given in the -pidfile option\n");
+ printf(" -keepstdin\n");
+ printf(" does not redirect stdin to /dev/null\n");
+
printf("\n");
}
Modified: commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c?rev=897073&r1=897072&r2=897073&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c Fri Jan 8 01:10:29 2010
@@ -619,8 +619,11 @@
/**
* Redirect stdin, stdout, stderr.
*/
-static void set_output(char *outfile, char *errfile) {
- freopen("/dev/null", "r", stdin);
+static void set_output(char *outfile, char *errfile, bool redirectstdin) {
+ if (redirectstdin==true) {
+ freopen("/dev/null", "r", stdin);
+ }
+
log_debug("redirecting stdout to %s and stderr to %s",outfile,errfile);
/* make sure the debug goes out */
@@ -751,7 +754,7 @@
}
envmask = umask(0077);
- set_output(args->outfile, args->errfile);
+ set_output(args->outfile, args->errfile, args->redirectstdin);
/* We have to fork: this process will become the controller and the other
will be the child */