summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-main.h
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r--xdelta3/xdelta3-main.h29
1 files changed, 19 insertions, 10 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index d52dfc1..ebceb39 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -2102,7 +2102,6 @@ main_merge_output (xd3_stream *stream, main_file *ofile)
2102#define MAX_SUBPROCS 4 /* max(source + copier + output, 2102#define MAX_SUBPROCS 4 /* max(source + copier + output,
2103 source + copier + input + copier). */ 2103 source + copier + input + copier). */
2104static pid_t ext_subprocs[MAX_SUBPROCS]; 2104static pid_t ext_subprocs[MAX_SUBPROCS];
2105static char* ext_tmpfile = NULL;
2106 2105
2107/* Like write(), applies to a fd instead of a main_file, for the pipe 2106/* Like write(), applies to a fd instead of a main_file, for the pipe
2108 * copier subprocess. Does not print an error, to facilitate ignoring 2107 * copier subprocess. Does not print an error, to facilitate ignoring
@@ -2169,11 +2168,29 @@ main_external_compression_finish (void)
2169 { 2168 {
2170 return ret; 2169 return ret;
2171 } 2170 }
2171
2172 ext_subprocs[i] = 0;
2172 } 2173 }
2173 2174
2174 return 0; 2175 return 0;
2175} 2176}
2176 2177
2178/* Kills any outstanding compression process. */
2179static void
2180main_external_compression_cleanup (void)
2181{
2182 int i;
2183
2184 for (i = 0; i < num_subprocs; i += 1)
2185 {
2186 if (! ext_subprocs[i]) { continue; }
2187
2188 kill (ext_subprocs[i], SIGTERM);
2189
2190 ext_subprocs[i] = 0;
2191 }
2192}
2193
2177/* This runs as a forked process of main_input_decompress_setup() to 2194/* This runs as a forked process of main_input_decompress_setup() to
2178 * copy input to the decompression process. First, the available 2195 * copy input to the decompression process. First, the available
2179 * input is copied out of the existing buffer, then the buffer is 2196 * input is copied out of the existing buffer, then the buffer is
@@ -3470,11 +3487,6 @@ main_cleanup (void)
3470 main_bdata = NULL; 3487 main_bdata = NULL;
3471 main_bsize = 0; 3488 main_bsize = 0;
3472 3489
3473#if EXTERNAL_COMPRESSION
3474 main_free (ext_tmpfile);
3475 ext_tmpfile = NULL;
3476#endif
3477
3478 main_lru_cleanup(); 3490 main_lru_cleanup();
3479 3491
3480 if (recode_stream != NULL) 3492 if (recode_stream != NULL)
@@ -3948,10 +3960,7 @@ main (int argc, char **argv)
3948 } 3960 }
3949 3961
3950#if EXTERNAL_COMPRESSION 3962#if EXTERNAL_COMPRESSION
3951 if (ext_tmpfile != NULL) 3963 main_external_compression_cleanup ();
3952 {
3953 unlink (ext_tmpfile);
3954 }
3955#endif 3964#endif
3956 3965
3957 main_file_cleanup (& ifile); 3966 main_file_cleanup (& ifile);