diff options
author | Werner Koch <[email protected]> | 2004-04-16 09:46:54 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-04-16 09:46:54 +0000 |
commit | e21bf7b9e059dc0ef97c6c8a866db3a266f3f647 (patch) | |
tree | c9da9440b686f62a7e58bbf0aa154d2f9311a540 /agent/gpg-agent.c | |
parent | * misc.c (setup_pinentry_env): New. (diff) | |
download | gnupg-e21bf7b9e059dc0ef97c6c8a866db3a266f3f647.tar.gz gnupg-e21bf7b9e059dc0ef97c6c8a866db3a266f3f647.zip |
* gpg-agent.c (main): Tell the logging code taht we are runnign
detached.
* logging.h (JNLIB_LOG_WITH_PREFIX): Add constants for the flag
values.
* logging.c (log_set_prefix): New flag DETACHED.
(fun_writer): Take care of this flag.
(log_test_fd): New.
Diffstat (limited to '')
-rw-r--r-- | agent/gpg-agent.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 0fc1bb8bf..18a456f19 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -389,7 +389,7 @@ main (int argc, char **argv ) /* Please note that we may running SUID(ROOT), so be very CAREFUL when adding any stuff between here and the call to INIT_SECMEM() somewhere after the option parsing */ - log_set_prefix ("gpg-agent", 1|4); + log_set_prefix ("gpg-agent", JNLIB_LOG_WITH_PREFIX|JNLIB_LOG_WITH_PID); /* Try to auto set the character set. */ set_native_charset (NULL); @@ -652,11 +652,13 @@ main (int argc, char **argv ) bind_textdomain_codeset (PACKAGE_GT, "UTF-8"); #endif - /* now start with logging to a file if this is desired */ + /* Now start with logging to a file if this is desired. */ if (logfile) { log_set_file (logfile); - log_set_prefix (NULL, 1|2|4); + log_set_prefix (NULL, (JNLIB_LOG_WITH_PREFIX + |JNLIB_LOG_WITH_TIME + |JNLIB_LOG_WITH_PID)); } /* Make sure that we have a default ttyname. */ @@ -754,7 +756,7 @@ main (int argc, char **argv ) exit (1); } else if (pid) - { /* we are the parent */ + { /* We are the parent */ char *infostr; close (fd); @@ -803,17 +805,20 @@ main (int argc, char **argv ) } /* end parent */ - /* this is the child */ + /* + This is the child + */ - /* detach from tty and put process into a new session */ + /* Detach from tty and put process into a new session */ if (!nodetach ) { int i; + unsigned int oldflags; - /* close stdin, stdout and stderr unless it is the log stream */ + /* Close stdin, stdout and stderr unless it is the log stream */ for (i=0; i <= 2; i++) { - if ( log_get_fd () != i) + if (!log_test_fd (i) ) close (i); } if (setsid() == -1) @@ -822,6 +827,9 @@ main (int argc, char **argv ) cleanup (); exit (1); } + + log_get_prefix (&oldflags); + log_set_prefix (NULL, oldflags | JNLIB_LOG_RUN_DETACHED); opt.running_detached = 1; } |