Changeset 2a2bb60
- Timestamp:
- Oct 17, 2003, 9:51:17 PM (19 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- e8b95f8
- Parents:
- 27c3a93
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r27c3a93 r2a2bb60 1 1 $Id$ 2 2 3 2.0.9-pre-3 4 Added testing feature for capturing stderr messages 5 from commands and displaying them in the errors buffer. 6 This feature is disabled by default. 7 Enable in owl.h with: OWL_STDERR_REDIR 1 8 3 9 2.0.9-pre-2 4 10 Better reporting of perl errors (both into the errqueue -
functions.c
rec6ff52 r2a2bb60 1972 1972 FILE *p; 1973 1973 1974 #if OWL_STDERR_REDIR 1975 redirect = " < /dev/null"; 1976 #endif 1977 1974 1978 if (argc<2) { 1975 1979 owl_function_error("Wrong number of arguments to the exec command"); -
owl.c
r27c3a93 r2a2bb60 21 21 #include <sys/stat.h> 22 22 #include "owl.h" 23 24 #if OWL_STDERR_REDIR 25 #include <sys/ioctl.h> 26 int stderr_replace(void); 27 void stderr_redirect(int rfd); 28 #endif 23 29 24 30 static const char fileIdent[] = "$Id$"; … … 42 48 ZNotice_t notice; 43 49 #endif 50 #if OWL_STDERR_REDIR 51 int newstderr; 52 #endif 44 53 45 54 argcsave=argc; … … 136 145 #endif 137 146 owl_global_set_haveaim(&g); 147 148 #if OWL_STDERR_REDIR 149 /* Do this only after we've started curses up... */ 150 newstderr = stderr_replace(); 151 #endif 152 138 153 139 154 /* create the owl directory, in case it does not exist */ … … 530 545 owl_function_makemsg("Unable to handle keypress"); 531 546 } 547 548 #if OWL_STDERR_REDIR 549 stderr_redirect(newstderr); 550 #endif 551 532 552 } 533 553 } … … 552 572 fprintf(stderr, " -t set the tty name\n"); 553 573 } 574 575 576 577 #if OWL_STDERR_REDIR 578 579 /* Replaces stderr with a pipe so that we can read from it. 580 * Returns the fd of the pipe from which stderr can be read. */ 581 int stderr_replace(void) { 582 int pipefds[2]; 583 if (0 != pipe(pipefds)) { 584 perror("pipe"); 585 owl_function_debugmsg("stderr_replace: pipe FAILED\n"); 586 return -1; 587 } 588 owl_function_debugmsg("stderr_replace: pipe: %d,%d\n", pipefds[0], pipefds[1]); 589 if (-1 == dup2(pipefds[1], 2 /*stderr*/)) { 590 owl_function_debugmsg("stderr_replace: dup2 FAILED (%s)\n", strerror(errno)); 591 perror("dup2"); 592 return -1; 593 } 594 return pipefds[0]; 595 } 596 597 /* Sends stderr (read from rfd) messages to a file */ 598 void stderr_redirect(int rfd) { 599 int navail, bread; 600 char *buf; 601 /*owl_function_debugmsg("stderr_redirect: called with rfd=%d\n", rfd);*/ 602 if (rfd<0) return; 603 if (-1 == ioctl(rfd, FIONREAD, (void*)&navail)) { 604 return; 605 } 606 /*owl_function_debugmsg("stderr_redirect: navail = %d\n", navail);*/ 607 if (navail<=0) return; 608 if (navail>256) { navail = 256; } 609 buf = owl_malloc(navail+1); 610 bread = read(rfd, buf, navail); 611 if (buf[navail-1] != '\0') { 612 buf[navail] = '\0'; 613 } 614 owl_function_error("Err: %s", buf); 615 owl_free(buf); 616 } 617 618 #endif /* OWL_STDERR_REDIR */ -
owl.h
r27c3a93 r2a2bb60 17 17 #endif 18 18 19 20 21 19 static const char owl_h_fileIdent[] = "$Id$"; 22 20 23 #define OWL_VERSION 2.0.9-pre-2 24 #define OWL_VERSION_STRING "2.0.9-pre-2" 21 #define OWL_VERSION 2.0.9-pre-3 22 #define OWL_VERSION_STRING "2.0.9-pre-3" 23 24 /* Feature that is being tested to redirect stderr through a pipe. 25 * There may still be some portability problems with this. */ 26 #define OWL_STDERR_REDIR 1 25 27 26 28 #define OWL_DEBUG 0 -
zwrite.c
r836ea3a3 r2a2bb60 154 154 openline=owl_malloc(strlen(zsigproc)+40); 155 155 strcpy(openline, zsigproc); 156 #if !(OWL_STDERR_REDIR) 156 157 strcat(openline, " 2> /dev/null"); 158 #endif 157 159 file=popen(openline, "r"); 158 160 owl_free(openline);
Note: See TracChangeset
for help on using the changeset viewer.