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 bin_PROGRAMS = @PACKAGE@-log @PACKAGE@-logserver-wrap
noinst_PROGRAMS = @PACKAGE@-test-logserver noinst_PROGRAMS = @PACKAGE@-test-logserver @PACKAGE@-log-stdin
@PACKAGE@_test_logserver_SOURCES = logserver.cc @PACKAGE@_test_logserver_SOURCES = logserver.cc
@PACKAGE@_test_logserver_LDADD = $(top_builddir)/lib/libUniSet2.la $(COMCPP_LIBS) @PACKAGE@_test_logserver_LDADD = $(top_builddir)/lib/libUniSet2.la $(COMCPP_LIBS)
......
...@@ -74,7 +74,7 @@ int main( int argc, char* argv[], char* envp[] ) ...@@ -74,7 +74,7 @@ int main( int argc, char* argv[], char* envp[] )
while( true ) while( true )
{ {
size_t r = read(0, buf, sizeof(buf)-1); size_t r = read(fileno(stdin), buf, sizeof(buf)-1);
if( r > 0 ) if( r > 0 )
{ {
buf[r] = '\0'; buf[r] = '\0';
......
...@@ -43,7 +43,6 @@ int main( int argc, char* argv[], char* envp[] ) ...@@ -43,7 +43,6 @@ int main( int argc, char* argv[], char* envp[] )
try try
{ {
/* Create a child to run command. */
switch( pid = fork() ) switch( pid = fork() )
{ {
case -1: case -1:
...@@ -57,11 +56,11 @@ int main( int argc, char* argv[], char* envp[] ) ...@@ -57,11 +56,11 @@ int main( int argc, char* argv[], char* envp[] )
/* Child. */ /* Child. */
close(cp[0]); close(cp[0]);
close( fileno(stderr) ); //close stderr close( fileno(stdout) );
dup2(fileno(stdout),fileno(stderr)); dup2(cp[1],fileno(stdout));
close(fileno(stdout)); /* Close current stdout. */ close( fileno(stderr) );
dup2(cp[1],fileno(stdout)); /* Make stdout go to write end of pipe. */ dup2(fileno(stdout),fileno(stderr));
execvpe(argv[3], argv + 3, envp); execvpe(argv[3], argv + 3, envp);
perror("No exec"); perror("No exec");
...@@ -90,7 +89,6 @@ int main( int argc, char* argv[], char* envp[] ) ...@@ -90,7 +89,6 @@ int main( int argc, char* argv[], char* envp[] )
ssize_t r = read(cp[0], &buf, sizeof(buf)-1 ); ssize_t r = read(cp[0], &buf, sizeof(buf)-1 );
if( r > 0 ) if( r > 0 )
{ {
cout << "***READ**" << endl;
buf[r] = '\0'; buf[r] = '\0';
zlog << buf; 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