diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-11-10 02:01:43 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-11-10 10:11:50 +0000 |
commit | 827b7dd75680b26e2bfddb0dac2f42f1dad69e7a (patch) | |
tree | 6e2f0010572a5073789163fd0abbf270f739e44a /wiretap/file_wrappers.c | |
parent | 630ccbe2d74338bac6d8abe69705cf0401baa8c1 (diff) |
Skip only the actual file descriptor close when writing to stdout.
Have a "this is stdout" flag for a wtap_dumper, and have "open the
standard output for dumping" routines that set that flag. When closing
a wtap_dumper, do most of the work regardless of whether we're writing
to the standard output or not (so that everything gets written out) and
only skip the closing of the underlying file descriptor.
Change-Id: I9f7e4d142b3bd598055d806b7ded1cb4c378de8e
Reviewed-on: https://code.wireshark.org/review/11673
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/file_wrappers.c')
-rw-r--r-- | wiretap/file_wrappers.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c index 5b4cbd27da..5918a55f6f 100644 --- a/wiretap/file_wrappers.c +++ b/wiretap/file_wrappers.c @@ -1719,9 +1719,15 @@ gzwfile_flush(GZWFILE_T state) } /* Flush out all data written, and close the file. Returns a Wiretap - error on failure; returns 0 on success. */ + error on failure; returns 0 on success. + + If is_stdout is true, do all of that except for closing the file + descriptor, as we don't want to close the standard output file + descriptor out from under the program (even though, if the program + is writing a capture file to the standard output, it shouldn't be + doing anything *else* on the standard output). */ int -gzwfile_close(GZWFILE_T state) +gzwfile_close(GZWFILE_T state, gboolean is_stdout) { int ret = 0; @@ -1732,8 +1738,10 @@ gzwfile_close(GZWFILE_T state) g_free(state->out); g_free(state->in); state->err = Z_OK; - if (ws_close(state->fd) == -1 && ret == 0) - ret = errno; + if (!is_stdout) { + if (ws_close(state->fd) == -1 && ret == 0) + ret = errno; + } g_free(state); return ret; } |