Changeset 2244836
- Timestamp:
- Jun 22, 2011, 12:37:22 AM (13 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- a6a9ddb
- Parents:
- bbb7876
- git-author:
- David Benjamin <davidben@mit.edu> (05/24/11 01:42:07)
- git-committer:
- David Benjamin <davidben@mit.edu> (06/22/11 00:37:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
rbbb7876 r2244836 450 450 451 451 /* Sends stderr (read from rfd) messages to the error console */ 452 void stderr_redirect_handler(const owl_io_dispatch *d, void *data)452 gboolean stderr_redirect_handler(GIOChannel *source, GIOCondition condition, void *data) 453 453 { 454 454 int navail, bread; 455 455 char buf[4096]; 456 int rfd = d->fd;456 int rfd = g_io_channel_unix_get_fd(source); 457 457 char *err; 458 458 459 if (rfd<0) return; 459 /* TODO: Use g_io_channel_read_line? We'd have to be careful about 460 * blocking on the read. */ 461 462 if (rfd<0) return TRUE; 460 463 if (-1 == ioctl(rfd, FIONREAD, &navail)) { 461 return ;464 return TRUE; 462 465 } 463 466 /*owl_function_debugmsg("stderr_redirect: navail = %d\n", navail);*/ 464 if (navail <= 0) return ;467 if (navail <= 0) return TRUE; 465 468 if (navail > sizeof(buf)-1) { 466 469 navail = sizeof(buf)-1; … … 468 471 bread = read(rfd, buf, navail); 469 472 if (bread == -1) 470 return ;473 return TRUE; 471 474 472 475 err = g_strdup_printf("[stderr]\n%.*s", bread, buf); … … 474 477 owl_function_log_err(err); 475 478 g_free(err); 479 return TRUE; 476 480 } 477 481 … … 521 525 /* Do this only after we've started curses up... */ 522 526 owl_function_debugmsg("startup: doing stderr redirection"); 523 owl_select_add_io_dispatch(stderr_replace(), OWL_IO_READ, &stderr_redirect_handler, NULL, NULL); 527 channel = g_io_channel_unix_new(stderr_replace()); 528 g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &stderr_redirect_handler, NULL); 529 g_io_channel_unref(channel); 524 530 #endif 525 531
Note: See TracChangeset
for help on using the changeset viewer.