* assuan-pipe-connect.c (assuan_pipe_connect2): New to extend
assuan_pipe_connect with some flags. Implemented a bitbucket for stderr.
This commit is contained in:
parent
fb23b0382d
commit
0d3ffd103d
@ -1,3 +1,9 @@
|
|||||||
|
2002-05-03 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan-pipe-connect.c (assuan_pipe_connect2): New to extend
|
||||||
|
assuan_pipe_connect with some flags. Implemented a bitbucket for
|
||||||
|
stderr.
|
||||||
|
|
||||||
2002-04-26 Werner Koch <wk@gnupg.org>
|
2002-04-26 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* Makefile.am: Create libtool libraries
|
* Makefile.am: Create libtool libraries
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "assuan-defs.h"
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
@ -102,8 +104,9 @@ do_deinit (ASSUAN_CONTEXT ctx)
|
|||||||
vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file
|
vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file
|
||||||
descriptors not to close in the child. */
|
descriptors not to close in the child. */
|
||||||
AssuanError
|
AssuanError
|
||||||
assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[],
|
assuan_pipe_connect2 (ASSUAN_CONTEXT *ctx, const char *name,
|
||||||
int *fd_child_list)
|
char *const argv[], int *fd_child_list,
|
||||||
|
unsigned int connect_flags)
|
||||||
{
|
{
|
||||||
static int fixed_signals = 0;
|
static int fixed_signals = 0;
|
||||||
AssuanError err;
|
AssuanError err;
|
||||||
@ -217,6 +220,23 @@ assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[],
|
|||||||
close (wp[0]);
|
close (wp[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((connect_flags & 1))
|
||||||
|
{ /* dup stderr to /dev/null so that the application output
|
||||||
|
won't get clobbered with output from the backend */
|
||||||
|
int fdzero = open ("/dev/null", O_WRONLY);
|
||||||
|
if (fdzero == -1)
|
||||||
|
{
|
||||||
|
LOGERROR1 ("can't open `/dev/null': %s\n", strerror (errno));
|
||||||
|
_exit (4);
|
||||||
|
}
|
||||||
|
if (dup2 (fdzero, 2) == -1)
|
||||||
|
{
|
||||||
|
LOGERROR1 ("dup2(dev/null, 2) failed: %s\n", strerror (errno));
|
||||||
|
_exit (4);
|
||||||
|
}
|
||||||
|
close (fdzero);
|
||||||
|
}
|
||||||
|
|
||||||
execv (name, argv);
|
execv (name, argv);
|
||||||
/* oops - use the pipe to tell the parent about it */
|
/* oops - use the pipe to tell the parent about it */
|
||||||
snprintf (errbuf, sizeof(errbuf)-1, "ERR %d can't exec `%s': %.50s\n",
|
snprintf (errbuf, sizeof(errbuf)-1, "ERR %d can't exec `%s': %.50s\n",
|
||||||
@ -254,6 +274,15 @@ assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[],
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AssuanError
|
||||||
|
assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[],
|
||||||
|
int *fd_child_list)
|
||||||
|
{
|
||||||
|
return assuan_pipe_connect2 (ctx, name, argv, fd_child_list, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +175,10 @@ int assuan_init_socket_server (ASSUAN_CONTEXT *r_ctx, int listen_fd);
|
|||||||
/*-- assuan-pipe-connect.c --*/
|
/*-- assuan-pipe-connect.c --*/
|
||||||
AssuanError assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name,
|
AssuanError assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name,
|
||||||
char *const argv[], int *fd_child_list);
|
char *const argv[], int *fd_child_list);
|
||||||
|
AssuanError assuan_pipe_connect2 (ASSUAN_CONTEXT *ctx, const char *name,
|
||||||
|
char *const argv[], int *fd_child_list,
|
||||||
|
unsigned int connect_flags);
|
||||||
|
|
||||||
/*-- assuan-socket-connect.c --*/
|
/*-- assuan-socket-connect.c --*/
|
||||||
AssuanError assuan_socket_connect (ASSUAN_CONTEXT *ctx, const char *name,
|
AssuanError assuan_socket_connect (ASSUAN_CONTEXT *ctx, const char *name,
|
||||||
pid_t server_pid);
|
pid_t server_pid);
|
||||||
|
Loading…
Reference in New Issue
Block a user