Commit 41cba1cc authored by Pavel Vainerman's avatar Pavel Vainerman

(Log): доделал утилиту log-wrap для "чтения" cerr и cout

parent 0217b4b1
bin_PROGRAMS = @PACKAGE@-log @PACKAGE@-log-stdin @PACKAGE@-logserver-wrap
noinst_PROGRAMS = @PACKAGE@-test-logserver
bin_PROGRAMS = @PACKAGE@-log @PACKAGE@-logserver-wrap
noinst_PROGRAMS = @PACKAGE@-test-logserver @PACKAGE@-log-stdin
@PACKAGE@_test_logserver_SOURCES = logserver.cc
@PACKAGE@_test_logserver_LDADD = $(top_builddir)/lib/libUniSet2.la $(COMCPP_LIBS)
......
......@@ -74,7 +74,7 @@ int main( int argc, char* argv[], char* envp[] )
while( true )
{
size_t r = read(0, buf, sizeof(buf)-1);
size_t r = read(fileno(stdin), buf, sizeof(buf)-1);
if( r > 0 )
{
buf[r] = '\0';
......
......@@ -43,7 +43,6 @@ int main( int argc, char* argv[], char* envp[] )
try
{
/* Create a child to run command. */
switch( pid = fork() )
{
case -1:
......@@ -57,11 +56,11 @@ int main( int argc, char* argv[], char* envp[] )
/* Child. */
close(cp[0]);
close( fileno(stderr) ); //close stderr
dup2(fileno(stdout),fileno(stderr));
close( fileno(stdout) );
dup2(cp[1],fileno(stdout));
close(fileno(stdout)); /* Close current stdout. */
dup2(cp[1],fileno(stdout)); /* Make stdout go to write end of pipe. */
close( fileno(stderr) );
dup2(fileno(stdout),fileno(stderr));
execvpe(argv[3], argv + 3, envp);
perror("No exec");
......@@ -90,7 +89,6 @@ int main( int argc, char* argv[], char* envp[] )
ssize_t r = read(cp[0], &buf, sizeof(buf)-1 );
if( r > 0 )
{
cout << "***READ**" << endl;
buf[r] = '\0';
zlog << buf;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment