* call-scd.c (start_scd): Send event-signal option. Always check

that the scdaemon is still running.

* gpg-agent.c (handle_signal): Do not use SIGUSR{1,2} anymore for
changing the verbosity.
This commit is contained in:
Werner Koch 2004-04-21 14:43:51 +00:00
parent 78f797d11d
commit 3d58329f67
4 changed files with 45 additions and 20 deletions

View File

@ -1,3 +1,11 @@
2004-04-21 Werner Koch <wk@gnupg.org>
* call-scd.c (start_scd): Send event-signal option. Always check
that the scdaemon is still running.
* gpg-agent.c (handle_signal): Do not use SIGUSR{1,2} anymore for
changing the verbosity.
2004-04-16 Werner Koch <wk@gnupg.org>
* gpg-agent.c (main): Tell the logging code taht we are runnign

View File

@ -33,6 +33,8 @@
#include <assert.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#ifdef USE_GNU_PTH
# include <pth.h>
#endif
@ -51,8 +53,8 @@ static ASSUAN_CONTEXT scd_ctx = NULL;
static pth_mutex_t scd_lock = PTH_MUTEX_INIT;
#endif
/* We need to keep track of the connection currently using the SCD.
For a pipe server this is all a NOP becuase the connection will
always have the conenction indicator -1. agent_reset_scd releases
For a pipe server this is all a NOP because the connection will
always have the connection indicator -1. agent_reset_scd releases
the active connection; i.e. sets it back to -1, so that a new
connection can start using the SCD. If we eventually allow
multiple SCD session we will either make scdaemon multi-threaded or
@ -195,6 +197,8 @@ start_scd (ctrl_t ctrl)
if (scd_ctx)
{
pid_t pid;
/* If we are not the connection currently using the SCD, return
an error. */
if (!active_connection)
@ -205,8 +209,19 @@ start_scd (ctrl_t ctrl)
else if (ctrl->connection_fd != active_connection_fd)
return unlock_scd (gpg_error (GPG_ERR_CONFLICT));
/* Okay, we scdaemon already started and used by us. */
return 0;
/* Okay, we already started the scdaemon and it is used by us.*/
/* We better do a sanity check now to see whether it has
accidently died. */
pid = assuan_get_pid (scd_ctx);
if (pid != (pid_t)(-1) && pid
&& ((rc=waitpid (pid, NULL, WNOHANG))==-1 || (rc == pid)) )
{
assuan_disconnect (scd_ctx);
scd_ctx = NULL;
}
else
return 0;
}
if (opt.verbose)
@ -255,6 +270,14 @@ start_scd (ctrl_t ctrl)
if (DBG_ASSUAN)
log_debug ("connection to SCdaemon established\n");
/* Tell the scdaemon that we want him to send us an event signal. */
{
char buf[100];
sprintf (buf, "OPTION event-signal=%d", SIGUSR2);
assuan_transact (scd_ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL);
}
return 0;
}

View File

@ -1059,15 +1059,11 @@ handle_signal (int signo)
break;
case SIGUSR1:
if (opt.verbose < 5)
opt.verbose++;
log_info ("SIGUSR1 received - verbosity set to %d\n", opt.verbose);
log_info ("SIGUSR1 received - no action defined\n");
break;
case SIGUSR2:
if (opt.verbose)
opt.verbose--;
log_info ("SIGUSR2 received - verbosity set to %d\n", opt.verbose );
log_info ("SIGUSR2 received - checking smartcard status\n");
break;
case SIGTERM:

View File

@ -312,15 +312,6 @@ implementation, which calls the scdaemon only once, it is not of much
use.
@item SIGUSR1
@cpindex SIGUSR1
This signal increases the verbosity of the logging by one up to a value
of 5.
@item SIGUSR2
@cpindex SIGUSR2
This signal decreases the verbosity of the logging by one.
@item SIGTERM
@cpindex SIGTERM
Shuts down the process but waits until all current requests are
@ -331,6 +322,13 @@ are still pending, a shutdown is forced.
@cpindex SIGINT
Shuts down the process immediately.
@item SIGUSR1
@itemx SIGUSR2
@cpindex SIGUSR1
@cpindex SIGUSR2
These signals are used for internal purposes.
@end table
@c