aboutsummaryrefslogtreecommitdiffstats
path: root/capture_loop.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2006-02-11 23:25:11 +0000
committerUlf Lamping <ulf.lamping@web.de>2006-02-11 23:25:11 +0000
commitcf94760fa4a1de9fdb1aa5a3152516699bceaf45 (patch)
tree1c665d6e6c1ad304187017b4cdbe4ecc3aba2532 /capture_loop.c
parentec37501696d809d932c6db398b71950b4beb4e36 (diff)
the point of no return ...
using dumpcap as the capture child for Ethereal. dumpcap is a plain console application now, even for Win32 (so no WinMain, create_console and special piping stuff reguired). The undocumented command line option -Z will switch dumpcap into "child mode", using binary instead of plain text output messages to communicate with a parent Ethereal. Ethereal's main.c no longer needs to distinguish between child mode or not, so some simplifying here. capture_sync.c has to call dumpcap in a "hidden window" mode using CreateProcess instead of spawnvp, otherwise an uggly console window would appear. The handles created by _pipe doesn't seem to be inheritable for this function, using CreatePipe instead. The file capture_loop.c is only needed by dumpcap, removed from Ethereal link objects. Some debugging aid added and other minor cleanup done. svn path=/trunk/; revision=17256
Diffstat (limited to 'capture_loop.c')
-rw-r--r--capture_loop.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/capture_loop.c b/capture_loop.c
index 58745e7c12..3ae13f0492 100644
--- a/capture_loop.c
+++ b/capture_loop.c
@@ -1100,19 +1100,22 @@ capture_loop_stop_signal_handler(int signo _U_)
static gboolean
signal_pipe_stopped(void)
{
- /* some news from our parent (signal pipe)? -> just stop the capture */
+ /* any news from our parent (stdin)? -> just stop the capture */
HANDLE handle;
DWORD avail = 0;
gboolean result;
- handle = (HANDLE) _get_osfhandle (0);
+ handle = (HANDLE) GetStdHandle(STD_INPUT_HANDLE);
result = PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL);
- /*g_warning("check pipe: handle: %x result: %u avail: %u", handle, result, avail);*/
-
if(!result || avail > 0) {
/* peek failed or some bytes really available */
+
+ /* XXX - if not piping from stdin this fails */
+ /*g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
+ "Signal pipe: handle: %x result: %u avail: %u", handle, result, avail);
+ return FALSE;*/
return TRUE;
} else {
/* pipe ok and no bytes available */
@@ -1247,10 +1250,10 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
inpkts = capture_loop_dispatch(capture_opts, &ld, errmsg, sizeof(errmsg));
#ifdef _WIN32
- /*fprintf(stderr, "fd: %u ret: %u\n", capture_opts->signal_pipe_fd, signal_pipe_stopped());*/
+ /*fprintf(stderr, "signal pipe ret: %u\n", signal_pipe_stopped());*/
/* any news from our parent (signal pipe)? -> just stop the capture */
- if (capture_opts->signal_pipe_fd != -1 && signal_pipe_stopped()) {
+ if (signal_pipe_stopped()) {
ld.go = FALSE;
}
#endif