Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 103905 Details for
Bug 138409
Attached patch for start-stop-daemon to redirect in/out when forking to background
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to start-stop-daemon.c
baselayout-1.12.6-redirect.patch (text/plain), 3.94 KB, created by
Iain Buchanan
on 2006-12-12 16:17:20 UTC
(
hide
)
Description:
patch to start-stop-daemon.c
Filename:
MIME Type:
Creator:
Iain Buchanan
Created:
2006-12-12 16:17:20 UTC
Size:
3.94 KB
patch
obsolete
>--- baselayout-1.12.6/src/start-stop-daemon.orig.c 2006-12-06 16:48:34.000000000 +0930 >+++ baselayout-1.12.6/src/start-stop-daemon.c 2006-12-08 09:53:18.000000000 +0930 >@@ -27,6 +27,10 @@ > * new root if -r option is used!). > * Daemon binary will be stat()ed correctly if it's going to be chrooted > * with -r|--chroot. >+ * >+ * Changes by Iain Buchanan <iaindb@netspace.net.au>: added to public domain. >+ * Added --stdin --stdout and --stderr for redirecting input and output (eg to >+ * vt's) when run with --background. > * > */ > >@@ -137,6 +141,9 @@ > static const char *schedule_str = NULL; > static const char *progname = ""; > static int nicelevel = 0; >+static const char *stdindev = NULL; >+static const char *stdoutdev = NULL; >+static const char *stderrdev = NULL; > > static struct stat exec_stat; > #if defined(OSHURD) >@@ -308,6 +315,9 @@ > " -o|--oknodo exit status 0 (not 1) if nothing done\n" > " -q|--quiet be more quiet\n" > " -v|--verbose be more verbose\n" >+" -0|--stdin <device> redirect stdin from <device> when run with --background\n" >+" -1|--stdout <device> redirect stdout to <device> when run with --background\n" >+" -2|--stderr <device> redirect stderr to <device> when run with --background\n" > "Retry <schedule> is <item>|/<item>/... where <item> is one of\n" > " -<signal-num>|[-]<signal-name> send that signal\n" > " <timeout> wait that many seconds\n" >@@ -490,6 +500,9 @@ > { "make-pidfile", 0, NULL, 'm'}, > { "retry", 1, NULL, 'R'}, > { "chdir", 1, NULL, 'd'}, >+ { "stdin", 1, NULL, '0'}, >+ { "stdout", 1, NULL, '1'}, >+ { "stderr", 1, NULL, '2'}, > { NULL, 0, NULL, 0} > }; > int c; >@@ -573,6 +586,16 @@ > case 'd': /* --chdir /new/dir */ > changedir = optarg; > break; >+ case '0': /* --stdin new_stdin */ >+ stdindev = optarg; >+ break; >+ case '1': /* --stdout new_stdout */ >+ stdoutdev = optarg; >+ break; >+ case '2': /* --stderr new_stderr */ >+ stderrdev = optarg; >+ break; >+ > default: > badusage(NULL); /* message printed by getopt */ > } >@@ -606,6 +629,10 @@ > if (background && !start) > badusage("--background is only relevant with --start"); > >+ if ((stdindev != NULL || stdoutdev != NULL || stderrdev != NULL) && !background) { >+ fprintf(stderr, "start-stop-daemon: redirecting stdin, stdout or stderr without --background\n"); >+ fprintf(stderr, "may stop you from interacting with this process from the terminal.\n"); >+ } > } > > #if defined(OSLinux) >@@ -1255,6 +1282,9 @@ > main(int argc, char **argv) > { > int devnull_fd = -1; >+ int stdin_fd = -1; >+ int stdout_fd = -1; >+ int stderr_fd = -1; > #ifdef HAVE_TIOCNOTTY > int tty_fd = -1; > #endif >@@ -1364,6 +1394,12 @@ > #endif > devnull_fd=open("/dev/null", O_RDWR); > } >+ if (stdindev != NULL) >+ stdin_fd=open(stdindev, O_RDWR | O_APPEND); >+ if (stdoutdev != NULL) >+ stdout_fd=open(stdoutdev, O_RDWR | O_APPEND); >+ if (stderrdev != NULL) >+ stderr_fd=open(stderrdev, O_RDWR | O_APPEND); > if (nicelevel) { > errno=0; > if ((nice(nicelevel)==-1) && (errno!=0)) >@@ -1407,9 +1443,7 @@ > close(tty_fd); > #endif > umask(022); /* set a default for dumb programs */ >- dup2(devnull_fd,0); /* stdin */ >- dup2(devnull_fd,1); /* stdout */ >- dup2(devnull_fd,2); /* stderr */ >+ > #if defined(OShpux) > /* now close all extra fds */ > for (i=sysconf(_SC_OPEN_MAX)-1; i>=3; --i) close(i); >@@ -1425,6 +1459,21 @@ > setpgid(0,0); > #endif > } >+ if (stdin_fd == -1) >+ dup2(devnull_fd,0); /* stdin */ >+ else >+ dup2(stdin_fd,0); /* stdin */ >+ >+ if (stdout_fd == -1) >+ dup2(devnull_fd,1); /* stdout */ >+ else >+ dup2(stdout_fd,1); /* stdout */ >+ >+ if (stderr_fd == -1) >+ dup2(devnull_fd,2); /* stderr */ >+ else >+ dup2(stderr_fd,2); /* stderr */ >+ > execv(startas, argv); > fatal("Unable to start %s: %s", startas, strerror(errno)); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 138409
: 103905