diff options
author | Ron Yorston <rmy@pobox.com> | 2020-08-05 15:33:12 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-08-05 15:33:12 +0100 |
commit | 4319228f3dcf3a5f941140482c30cca227c6ed0b (patch) | |
tree | 6d1203b9607d2f60ef503555872391d881da6163 /win32 | |
parent | b5fb54b4ac78c801dc4fa7a5b12dd6e296e52f3f (diff) | |
download | busybox-w32-4319228f3dcf3a5f941140482c30cca227c6ed0b.tar.gz busybox-w32-4319228f3dcf3a5f941140482c30cca227c6ed0b.tar.bz2 busybox-w32-4319228f3dcf3a5f941140482c30cca227c6ed0b.zip |
win32: move code to fork (de)compressor to a function
Use a new common function, mingw_fork_compressor(), to implement
fork_transformer() in open_transformer.c and vfork_compressor()
in tar.c.
Saves 160 bytes.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/popen.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/win32/popen.c b/win32/popen.c index 0da5cde23..8810b8de0 100644 --- a/win32/popen.c +++ b/win32/popen.c | |||
@@ -306,3 +306,25 @@ int mingw_pclose(FILE *fp) | |||
306 | 306 | ||
307 | return (ret == WAIT_OBJECT_0) ? 0 : -1; | 307 | return (ret == WAIT_OBJECT_0) ? 0 : -1; |
308 | } | 308 | } |
309 | |||
310 | /* Used with mode "w" and a compressor when creating a compressed tar | ||
311 | * file; with mode "r" and a decompressor in open_transformer. */ | ||
312 | pid_t mingw_fork_compressor(int fd, const char *compressor, const char *mode) | ||
313 | { | ||
314 | char *cmd; | ||
315 | int fd1; | ||
316 | pid_t pid; | ||
317 | |||
318 | if (find_applet_by_name(compressor) >= 0) | ||
319 | cmd = xasprintf("%s --busybox %s -cf -", bb_busybox_exec_path, | ||
320 | compressor); | ||
321 | else | ||
322 | cmd = xasprintf("%s -cf -", compressor); | ||
323 | |||
324 | if ((fd1 = mingw_popen_fd(cmd, mode, fd, &pid)) == -1) | ||
325 | bb_perror_msg_and_die("can't execute '%s'", compressor); | ||
326 | |||
327 | free(cmd); | ||
328 | xmove_fd(fd1, fd); | ||
329 | return pid; | ||
330 | } | ||