[Pkg-privacy-commits] [onioncat] 192/340: OC should now detach properly from console

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository onioncat.

commit 7b204ec6b42ba3a7ece9cb7e22e9822f7607db7e
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Thu Sep 17 12:55:32 2009 +0000

    OC should now detach properly from console
    
    git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@513 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 configure  | 22 +++++++++++-----------
 src/ocat.c | 29 ++++++++++++-----------------
 2 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/configure b/configure
index c5dd9d5..9f115e4 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.62 for onioncat 0.2.0.r512.
+# Generated by GNU Autoconf 2.62 for onioncat 0.2.0.r513.
 #
 # Report bugs to <rahra at cypherpunk.at>.
 #
@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='onioncat'
 PACKAGE_TARNAME='onioncat'
-PACKAGE_VERSION='0.2.0.r512'
-PACKAGE_STRING='onioncat 0.2.0.r512'
+PACKAGE_VERSION='0.2.0.r513'
+PACKAGE_STRING='onioncat 0.2.0.r513'
 PACKAGE_BUGREPORT='rahra at cypherpunk.at'
 
 ac_subst_vars='SHELL
@@ -1259,7 +1259,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures onioncat 0.2.0.r512 to adapt to many kinds of systems.
+\`configure' configures onioncat 0.2.0.r513 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1329,7 +1329,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of onioncat 0.2.0.r512:";;
+     short | recursive ) echo "Configuration of onioncat 0.2.0.r513:";;
    esac
   cat <<\_ACEOF
 
@@ -1421,7 +1421,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-onioncat configure 0.2.0.r512
+onioncat configure 0.2.0.r513
 generated by GNU Autoconf 2.62
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1435,7 +1435,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by onioncat $as_me 0.2.0.r512, which was
+It was created by onioncat $as_me 0.2.0.r513, which was
 generated by GNU Autoconf 2.62.  Invocation command line was
 
   $ $0 $@
@@ -2084,7 +2084,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='onioncat'
- VERSION='0.2.0.r512'
+ VERSION='0.2.0.r513'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2235,7 +2235,7 @@ ac_config_headers="$ac_config_headers config.h"
 
 
 cat >>confdefs.h <<\_ACEOF
-#define SVN_REVISION "512"
+#define SVN_REVISION "513"
 _ACEOF
 
 
@@ -5208,7 +5208,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by onioncat $as_me 0.2.0.r512, which was
+This file was extended by onioncat $as_me 0.2.0.r513, which was
 generated by GNU Autoconf 2.62.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5261,7 +5261,7 @@ Report bugs to <bug-autoconf at gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-onioncat config.status 0.2.0.r512
+onioncat config.status 0.2.0.r513
 configured by $0, generated by GNU Autoconf 2.62,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
diff --git a/src/ocat.c b/src/ocat.c
index a0c93ef..89cbbf5 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -125,6 +125,18 @@ void background(void)
 
       case 0:
          log_msg(LOG_INFO, "process backgrounded by parent %d, new pid = %d", ppid, getpid());
+         (void) umask(0);
+         if (setsid() == -1)
+            log_msg(LOG_ERR, "could not set process group ID: \"%s\"", strerror(errno));
+         if (chdir("/") == -1)
+            log_msg(LOG_ERR, "could not change directory to /: \"%s\"", strerror(errno));
+         // redirect standard files to /dev/null
+         if (!freopen( "/dev/null", "r", stdin))
+            log_msg(LOG_ERR, "could not reconnect stdin to /dev/null: \"%s\"", strerror(errno));
+         if (!freopen( "/dev/null", "w", stdout))
+            log_msg(LOG_ERR, "could not reconnect stdout to /dev/null: \"%s\"", strerror(errno));
+         if (!freopen( "/dev/null", "w", stderr))
+            log_msg(LOG_ERR, "could not reconnect stderr to /dev/null: \"%s\"", strerror(errno));
          return;
 
       default:
@@ -223,7 +235,6 @@ int main(int argc, char *argv[])
    int c, runasroot = 0;
    struct passwd *pwd, pwdm;
    int urlconv = 0;
-   int nullfd;
 
    snprintf(def, 100, "127.0.0.1:%d", OCAT_LISTEN_PORT);
 
@@ -466,22 +477,6 @@ int main(int argc, char *argv[])
    if (CNF(create_clog))
       open_connect_log(pwd->pw_dir);
 
-   // reconnect stdio if logfile ok and daemonized
-   if (CNF(daemon))
-   {
-      if ((nullfd = open("/dev/null", O_RDWR)) != -1)
-      {
-         oe_close(0);
-         dup(nullfd);
-         oe_close(1);
-         dup(nullfd);
-         oe_close(2);
-         dup(nullfd);
-      }
-      else
-         log_msg(LOG_ERR, "could not reconnect stdio to /dev/null: \"%s\"", strerror(errno));
-   }
-
    // create socks connector thread and communication queue
    if (pipe(CNF(socksfd)) == -1)
       log_msg(LOG_EMERG, "couldn't create socks connector pipe: \"%s\"", strerror(errno)), exit(1);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git



More information about the Pkg-privacy-commits mailing list